home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / OpenDoc Development / Debugging Support / OpenDoc Source Code / Layout / Frame.cpp < prev    next >
Encoding:
Text File  |  1996-04-22  |  78.4 KB  |  2,689 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        Frame.cpp
  3.  
  4.     Contains:    Implementation of ODFrame
  5.  
  6.     Owned by:    Joshua Susser
  7.  
  8.     Copyright:    © 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.     
  12.          <3>     3/26/96    CC        1329842: kODPropLinkStatus is not a
  13.                                     required property.
  14.          <2>     3/15/96    CC        1329241: InitFrameNonPersistent: Initialize
  15.                                     fLinkStatus.
  16.                                     1329268: ChangeLinkStatus: Look for source
  17.                                     frame if no containing frame.
  18.         <74>     11/2/95    RR        #1298614 Check for NULL su in PrepareToSwap
  19.         <73>     11/1/95    JBS        1289931 GM: move release calls from
  20.                                     somUninit to Release all, use SafeRelease
  21.         <72>    10/24/95    TÇ        Removed two errant semicolons introduced
  22.                                     with fix of #1288922 don't force
  23.                                     DrawActiveBorder, wait for Window::Update
  24.         <71>    10/24/95    jpa        1293441: Ignore exceptions from
  25.                                     DisplayFrame{Closed,Removed}.
  26.         <70>    10/18/95    JBS        1288922 don't force DrawActiveBorder, wait
  27.                                     for Window::Update
  28.         <69>    10/17/95    jpa        1292659: Fixed leaks if parts throw
  29.         <68>     10/9/95    JBS        1290561 GM: ChangeLinkStatus dirties draft
  30.                                     unnecessarily; 1289931 GM: release objects
  31.                                     in ReleaseAll, not somUninit
  32.         <67>     10/8/95    TJ        Fixes Recomended by Refball
  33.         <66>     9/21/95    JBS        1284283 window refcounting in PrepareToSwap
  34.         <65>     9/13/95    DM        1277216 GM:API return no ODPoints nor
  35.                                     ODPolygons
  36.         <64>     9/12/95    JBS        1283657 part->FacedAdded called twice in
  37.                                     Frame::FacetAdded
  38.         <63>      9/8/95    JBS        1281770 Frame::ChangeLinkStatus short
  39.                                     circuits
  40.         <62>      9/8/95    TÇ        1281096 FB2:Many constants in ODTypesB
  41.                                     without kOD prefix!
  42.         <61>      9/6/95    VL        1270294: Added and use
  43.                                     kFrameIsInRemoveFrame to avoid recursive
  44.                                     removal. Removed CHECKVALID in GetID.
  45.         <60>     8/31/95    JBS        1278337 error code cleanup
  46.         <59>     8/25/95    JBS        1263078 FB: fix part editor swapping;
  47.                                     1278052 FB: add InLimbo flag
  48.         <58>     8/17/95    CC        1273056: ContentUpdated acquires wrong
  49.                                     part.
  50.         <57>     8/16/95    NP        1274946: ErrorDef.idl problems. Add include
  51.                                     file.
  52.         <56>     8/12/95    TÇ        1276807 Opt./Bug: use StdTypIO routines for
  53.                                     portable streaming & smaller footprint
  54.         <55>      8/7/95    JBS        1262428 ASSERT in AcquirePart if part NULL;
  55.                                     1265721 don't purge facets' if invalid
  56.         <54>      8/3/95    RR        #1257260: Collapse B classes. Remove
  57.                                     somInit methods. Don't call IsInitialized
  58.                                     or SubclassResponsibility
  59.         <53>     7/27/95    JBS        1231232 SetContainingFrame - remove part
  60.                                     notification
  61.                                     1264303 AcquireContainingFrame - don't lazy
  62.                                     internalize if IsRoot
  63.         <52>     7/27/95    DM        #1270320: Mem leaks: must cast when
  64.                                     assigning from temp ref to another in
  65.                                     EditInLink and ContentUpdated
  66.         <51>     7/26/95    DM        #1270320: Memory leak fixes. delete
  67.                                     typeString returns from GetType in
  68.                                     Externalize and CloneInto
  69.         <50>      7/3/95    RR        1242642 BB: refcounting. SetContainingFrame
  70.                                     needed to Acquire before calling
  71.                                     window->CloseAndRemove.
  72.         <49>     6/29/95    DM        1242642 BB: refcounting: acquire member
  73.                                     vars (not locals) when possible, add
  74.                                     "Acquire" to names of local "ReadIfAny"
  75.                                     functions, release biasTransform    in
  76.                                     InitFrameFromStorage.
  77.         <48>     6/28/95    RR        1242642 BB Mostly ref counting. Release
  78.                                     window in CLose and Remove
  79.         <47>     6/23/95    JBS        1261323 add isSubframe param to InitFrame;
  80.                                     1238245 (done) InitFrame throws error on
  81.                                     non-subframe recursive embed
  82.         <46>     6/23/95    JBS        1251627 fix refcounting throughout file
  83.         <45>     6/21/95    JBS        1238245: (not done) InitFrame check for
  84.                                     recursive embedding; 1243657 SetWindow
  85.                                     throws if not root frame
  86.         <44>     6/20/95    JBS        1257315 change AcquireWindow to GetWindow
  87.         <43>     5/31/95    JBS        1250140 fixed refcount bug in AcquirePart
  88.         <42>     5/26/95    RR        #1251403: Multithreading naming support
  89.         <41>     5/17/95    RR        #1250135/1250137/1250143 Getters increment
  90.                                     refcount
  91.         <40>     5/17/95    JBS        1245283 Undoable frame deletion - close
  92.                                     part windows in SetContainingFrame; 1242496
  93.                                     change SOM_CATCH to SOM_TRY; 1250140 bump
  94.                                     refcount in AcquireContainingFrame, AcquirePart,
  95.                                     AcquireWindow
  96.         <39>     5/15/95    JBS        1245156 implement Purge
  97.         <38>      5/5/95    TJ        Put "VOID" into CHECKVALID since #$&* SCpp
  98.                                     won't take empty macro arguments.
  99.         <37>      5/4/95    JBS        1243651 added CHECKVALID to most methods,
  100.                                     and fixed ternalization to respect
  101.                                     fValidState
  102.         <36>     4/27/95    JBS        1209506 $5 comments eliminated
  103.         <35>     4/25/95    JBS        1242496 use SOM_TRY, etc. for exception
  104.                                     handling; 1241983 Externalize assumes
  105.                                     containing frame is persistent; 1183059
  106.                                     throw kODErrIllegalNullStorageUnitInput if
  107.                                     SU is nil; 1242527  AcquireContainingFrame
  108.                                     should not write SU; 1242546  Frame should
  109.                                     compute IsRoot from contFrame
  110.         <34>     4/14/95    TÇ        #1235279 BB: InfoUtil & StdTypIO functions
  111.                                     should take Environment* and SU* when
  112.                                     possible.  Also Clone a little better to
  113.                                     help out Save A Copy.
  114.         <33>     4/13/95    JBS        1211972 don't mark draft dirty if frame is
  115.                                     non-persistent;1233726 Frame::CloneInto
  116.                                     should call part->ClonePartInfo;1238250
  117.                                     Frame PartInfo should have multiple
  118.                                     values;1237963 don't validate
  119.                                     ContainingFrame property on init
  120.         <32>      4/3/95    CC        1234631: ChangeLinkStatus: Set _fLinkStatus
  121.                                     BEFORE notifying the part!
  122.         <31>     3/28/95    JBS        1229656 implemented EditInLink
  123.         <30>     3/28/95    JBS        1229656 add EditInLink()
  124.         <29>      3/8/95    JBS        1165158 AdjustBorderShape implementation
  125.         <28>     2/24/95    CC        Commented out redefinition of
  126.                                     ODFrameMethodDebug.
  127.         <27>     2/15/95    JBS        1198600 code review cleanup; 1195854 added
  128.                                     SetDirty, dirty/write properties
  129.                                     individually; 1189547 don't allow viewType
  130.                                     and pres to be NULL; 1183059 throw if NULL
  131.                                     su in InitFrameFromStorage; 1206295 don't
  132.                                     externalize UsedShape
  133.         <26>     1/25/95    CC        1206295: (for JBS) Temporarily add
  134.         <25>     1/20/95    JBS        1195017, 1205669: part API changes
  135.         <24>     11/1/94    CC        1196908 - SetContainingFrame: remove all
  136.                                     facets displaying this frame and call
  137.                                     ODPart::FacetRemoved();
  138.                                     FacetRemoved(): Guard against facets not in
  139.                                     the collection of display facets.
  140.                                     somUninit(): Fixed memory leak by deleting
  141.                                     fFacets collection.
  142.         <23>     9/29/94    JBS        1188214: more coord bias impl
  143.         <22>     9/26/94    JBS        1186332, 1188981 - nonpersistence; 1183568
  144.                                     - keep fIsDirty flag
  145.         <21>     9/22/94    JBS        1188214: coordinate bias implementation
  146.         <20>      9/7/94    CC        #1185056 - Use StdTypIO methods to
  147.                                     internalize/externalize fLinkStatus field.
  148.         <19>      9/6/94    CC        1153777- Implement GetLinkStatus(),
  149.                                     ChangeLinkStatus(), and ContentUpdated(),
  150.                                     and maintain the persistent fLinkStatus
  151.                                     field.
  152.         <18>     8/31/94    TÇ        #1183129, #1183116, #1183119, #1183111:
  153.                                     Lots of ErrorCode cleanup.
  154.         <17>     8/31/94    VL        1183174: Fixed CloneInto to avoid multiple
  155.                                     cloning. Removed CloneTo which was
  156.                                     commented out in <14>. Removed CMDraft.xh
  157.                                     because we are not depending on it with the
  158.                                     new cloning mechanism.
  159.         <16>     8/30/94    TÇ        #1183567 StdTypIO routine implementation.
  160.                                     Added Get/SetProp for time_t, ODPoint,
  161.                                     ODRect, Strong/WeakStorageUnitRefs.  Use
  162.                                     Get/SetProp routines for
  163.                                     Strong/WeakStorageUnitRefs.
  164.         <15>     8/29/94    TÇ        #1183567 StdTypIO routine implementation &
  165.                                     fixup
  166.         <14>     8/26/94    VL        1183174: Implemented CloneInto & removed
  167.                                     CloneTo.
  168.         <13>     8/19/94    TÇ        #1180922 Need to Stop using obsolete types
  169.                                     (kOD ID) and fixed a nasty bug where
  170.                                     destPartId was not being initialized to 0
  171.                                     in CloneTo which was causing a crash in
  172.                                     Bento.
  173.         <12>     8/18/94    jpa        Filled in imaging factories [1180387]
  174.         <11>     8/16/94    TÇ        #1180922  Remove more obsolete types from
  175.                                     StdTypes.idl.  Localized kODPartInfo to
  176.                                     this file.
  177.         <10>     8/16/94    VL        1143605: Fixed parameters to CloneInto.
  178.          <9>     8/15/94    JBS        1180387: added Imaging factory methods
  179.          <8>     8/12/94    JBS        1179920: move fWindow from Facet to Frame
  180.          <7>     8/11/94    VL        1180299: Use modified CreateView.
  181.          <6>     8/10/94    JBS        1179919: coordinate system bias changes;
  182.                                     1179920: Frame::AcquireWindow()
  183.          <5>      8/5/94    JBS        #1179151 Part API cleanup
  184.          <4>     7/15/94    TÇ        #ifdef'd out externalization of viewtype &
  185.                                     presentation for now to get the Externalize
  186.                                     method to not crash.
  187.          <3>      7/7/94    JBS        added ::ReleaseAll()
  188.          <2>     6/30/94    jpa        Include Draft.xh, not CMDraft.h.
  189.          <1>     6/30/94    JBS        first checked in
  190.          <0>     6/29/94    SV        SOMverted
  191.     In Progress:
  192.         
  193. */
  194.  
  195. #define ODFrame_Class_Source
  196.  
  197. #ifndef _ALTPOINT_
  198. #include <AltPoint.h>
  199. #endif
  200.  
  201. #ifndef SOM_ODFrame_xih
  202. #define VARIABLE_MACROS
  203. #include <Frame.xih>
  204. #endif
  205.  
  206. #ifndef _PLFMDEF_
  207. #include "PlfmDef.h"
  208. #endif
  209.  
  210. #ifndef SOM_ODFrameFacetIterator_xh
  211. #include <FrFaItr.xh>
  212. #endif
  213.  
  214. #ifndef SOM_ODFacet_xh
  215. #include <Facet.xh>
  216. #endif
  217.  
  218. #ifndef SOM_ODPart_xh
  219. #include <Part.xh>
  220. #endif
  221.  
  222. #ifndef SOM_ODSession_xh
  223. #include <ODSessn.xh>
  224. #endif
  225.  
  226. #ifndef SOM_ODStorageUnit_xh
  227. #include <StorageU.xh>
  228. #endif
  229.  
  230. #ifndef SOM_ODDraft_xh
  231. #include <Draft.xh>
  232. #endif
  233.  
  234. #ifndef SOM_ODDocument_xh
  235. #include <Document.xh>
  236. #endif
  237.  
  238. #ifndef SOM_ODStorageUnitCursor_xh
  239. #include <SUCursor.xh>
  240. #endif
  241.  
  242. #ifndef SOM_ODStorageUnitView_xh
  243. #include <SUView.xh>
  244. #endif
  245.  
  246. #ifndef SOM_ODCanvas_xh
  247. #include <Canvas.xh>
  248. #endif
  249.  
  250. #ifndef SOM_ODShape_xh
  251. #include <Shape.xh>
  252. #endif
  253.  
  254. #ifndef SOM_ODTransform_xh
  255. #include <Trnsform.xh>
  256. #endif
  257.  
  258. #ifndef ODWindowState_Class_Source
  259. #include <WinStat.xh>
  260. #endif
  261.  
  262. #ifndef SOM_ODWindow_xh
  263. #include <Window.xh>
  264. #endif
  265.  
  266. #ifndef SOM_ODWindowIterator_xh
  267. #include <WinIter.xh>
  268. #endif
  269.  
  270. #ifndef SOM_ODArbitrator_xh
  271. #include <Arbitrat.xh>
  272. #endif
  273.  
  274. #ifndef SOM_Module_OpenDoc_Foci_defined
  275. #include <Foci.xh>
  276. #endif
  277.  
  278. #ifndef _ISOSTR_
  279. #include "ISOStr.h"
  280. #endif
  281.  
  282. #ifndef _ODUTILS_
  283. #include <ODUtils.h>
  284. #endif
  285.  
  286. #ifndef _DOCUTILS_
  287. #include <DocUtils.h>
  288. #endif
  289.  
  290. #ifndef SOM_Module_OpenDoc_StdProps_defined
  291. #include <StdProps.xh>
  292. #endif
  293.  
  294. #ifndef SOM_Module_OpenDoc_StdTypes_defined
  295. #include <StdTypes.xh>
  296. #endif
  297.  
  298. #ifndef _EXCEPT_
  299. #include "Except.h"
  300. #endif
  301.  
  302. #ifndef _ORDCOLL_
  303. #include "OrdColl.h"
  304. #endif
  305.  
  306. #ifndef _ODMEMORY_
  307. #include "ODMemory.h"
  308. #endif
  309.  
  310. #ifndef _ODTYPES_
  311. #include <ODTypes.h>
  312. #endif
  313.  
  314. #ifndef _AEHSHTBL_
  315. #include "AEHshTbl.h"
  316. #endif
  317.  
  318. #ifndef _STORUTIL_
  319. #include <StorUtil.h>
  320. #endif
  321.  
  322. #ifndef _STDTYPIO_
  323. #include <StdTypIO.h>
  324. #endif
  325.  
  326. #ifndef _ODDEBUG_
  327. #include "ODDebug.h"
  328. #endif
  329.  
  330. #ifndef _BIAS_
  331. #include "bias.h"
  332. #endif
  333.  
  334. #ifndef _TEMPOBJ_
  335. #include "TempObj.h"
  336. #endif
  337.  
  338. #ifndef _UTILERRS_
  339. #include "UtilErrs.h"
  340. #endif
  341.  
  342. #pragma segment ODFrame
  343.  
  344. //==============================================================================
  345. // Debugging
  346. //==============================================================================
  347.  
  348. //#undef    ODFrameMethodDebug
  349. //#define ODFrameMethodDebug(c,m) PRINT(">>%s::%s\n",c,m)
  350.  
  351. //==============================================================================
  352. // Constants
  353. //==============================================================================
  354.  
  355.     // dirty mask
  356.     const ODULong kNotDirty                    = 0x0000UL;
  357.     const ODULong kContainingFrameDirty        = 0x0001UL;
  358.     const ODULong kFrameShapeDirty            = 0x0002UL;
  359.     const ODULong kInternalTransformDirty    = 0x0004UL;
  360.     const ODULong kPartDirty                = 0x0008UL;
  361.     const ODULong kPartInfoDirty            = 0x0010UL;
  362.     const ODULong kViewTypeDirty            = 0x0020UL;
  363.     const ODULong kPresentationDirty        = 0x0040UL;
  364.     const ODULong kFrameGroupDirty            = 0x0080UL;
  365.     const ODULong kSequenceNumberDirty        = 0x0100UL;
  366.     const ODULong kLinkStatusDirty            = 0x0200UL;
  367.     const ODULong kFlagsDirty                = 0x0400UL;
  368.     const ODULong kAllDirty                    = 0xFFFFUL;
  369.  
  370.     // valid mask
  371.     const ODUShort kFrameIsValid    = 0x0000U;
  372.     const ODUShort kFrameIsRemoved    = 0x0001U;
  373.     const ODUShort kFrameIsClosed    = 0x0002U;
  374.     const ODUShort kFrameIsInRelease    = 0x0004U;
  375.  
  376.     const ODULong kODStorageUnitRefLen = 4UL;
  377.  
  378. //==============================================================================
  379. // Macros
  380. //==============================================================================
  381.  
  382. #define CHECKVALID(RET) if ( _fValidState == kFrameIsValid ) ; else \
  383.                             { ODSetSOMException(ev, kODErrInvalidFrame); return RET;}
  384. #define VOID /**/
  385.  
  386.  
  387.  
  388. //==============================================================================
  389. // ODFrame
  390. //==============================================================================
  391.  
  392. //------------------------------------------------------------------------------
  393. // ODFrame: GetID
  394. //------------------------------------------------------------------------------
  395.  
  396. SOM_Scope ODID  SOMLINK ODFrameGetID(ODFrame *somSelf, Environment *ev)
  397. {
  398.     ODFrameData *somThis = ODFrameGetData(somSelf);
  399.     ODFrameMethodDebug("ODFrame","GetID");
  400.     
  401.     ODID id = 0;
  402.     
  403.     if ( _fNPID != 0 )
  404.         id = _fNPID;
  405.     else
  406.     {
  407.         SOM_TRY
  408.             id = parent_GetID(somSelf, ev);
  409.         SOM_CATCH_ALL
  410.             id = 0;
  411.         SOM_ENDTRY
  412.     }
  413.     return id;
  414. }
  415.  
  416. //------------------------------------------------------------------------------
  417. // ODFrame: AcquireContainingFrame
  418. //------------------------------------------------------------------------------
  419.  
  420. SOM_Scope ODFrame*  SOMLINK ODFrameAcquireContainingFrame(ODFrame *somSelf, Environment *ev)
  421. {
  422.     ODFrameData *somThis = ODFrameGetData(somSelf);
  423.     ODFrameMethodDebug("ODFrame","AcquireContainingFrame");
  424.  
  425.     CHECKVALID(kODNULL);
  426.     
  427.     ODFrame* contFrame = kODNULL;
  428.     SOM_TRY
  429.         ODStorageUnit* su = somSelf->GetStorageUnit(ev);
  430.         ODID frameID = 0;
  431.     
  432.         // if there is no containing frame, and this is not a root frame,
  433.         // and this is not a non-persistent frame, we should
  434.         // try to get the containing frame from the storage unit
  435.         if ( !_fContainingFrame && !_fIsRoot && su )
  436.         {
  437.             frameID = ODGetWeakSURefProp(ev, su, kODPropContainingFrame, kODWeakStorageUnitRef);
  438.             if ( frameID )
  439.                 _fContainingFrame = _fDraft->AcquireFrame(ev, frameID);
  440.         }
  441.         contFrame = _fContainingFrame;
  442.         // bump ref count for caller
  443.         ODAcquireObject(ev, _fContainingFrame);
  444.     SOM_CATCH_ALL
  445.         contFrame = kODNULL;
  446.     SOM_ENDTRY
  447.     return contFrame;
  448. }
  449.  
  450. SOM_Scope void  SOMLINK ODFrameSetContainingFrame(ODFrame *somSelf, Environment *ev,
  451.         ODFrame* frame)
  452. {
  453.     ODFrameData *somThis = ODFrameGetData(somSelf);
  454.     ODFrameMethodDebug("ODFrame","SetContainingFrame");
  455.  
  456.     CHECKVALID( VOID );
  457.     
  458.     ODSession* session = kODNULL;
  459.     ODWindowState* winState = kODNULL;
  460.     ODWindowIterator* windows = kODNULL;    ODVolatile(windows);
  461.     ODWindow* win = kODNULL;
  462.     
  463.     SOM_TRY
  464.         // when setting contFrame to NULL, make sure it has no facets
  465.         if ( (frame == kODNULL) && _fFacets && (_fFacets->Count() != 0) )
  466.             THROW(kODErrFrameHasFacets);
  467.     
  468.         ODAcquireObject(ev, frame);
  469.         ODReleaseObject(ev, _fContainingFrame);
  470.         _fContainingFrame = frame;
  471.         _fIsRoot = (frame == kODNULL);
  472.         
  473.         // close any part windows with sourceFrame of this frame or an embedded frame.
  474.         if ( frame == kODNULL )
  475.         {
  476.             TempODPart tempPart = somSelf->AcquirePart(ev);
  477.             session = tempPart->GetStorageUnit(ev)->GetSession(ev);
  478.             winState = session->GetWindowState(ev);
  479.             windows = winState->CreateWindowIterator(ev);
  480.             for ( win = windows->First(ev);
  481.                     windows->IsNotComplete(ev);
  482.                     win = windows->Next(ev) )
  483.             {
  484.                 TempODFrame testFrame = win->AcquireSourceFrame(ev);
  485.                 while ( testFrame != kODNULL )
  486.                 {
  487.                     if ( testFrame == somSelf )
  488.                     {
  489.                         win->Acquire(ev);
  490.                         win->CloseAndRemove(ev);
  491.                         ODReleaseObject(ev, testFrame); // sets to kODNULL
  492.                     }
  493.                     else
  494.                     {
  495.                         ODFrame* spam = testFrame;
  496.                         TempODFrame oldFrame = spam;
  497.                         testFrame = kODNULL; // to avoid double Release if following fails
  498.                         testFrame = oldFrame->AcquireContainingFrame(ev);
  499.                     }
  500.                 }
  501.             }
  502.             ODDeleteObject(windows);
  503.         }
  504.         
  505.         somSelf->SetDirty(ev, kContainingFrameDirty);
  506.     SOM_CATCH_ALL
  507.         ODDeleteObject(windows);
  508.     SOM_ENDTRY
  509. }
  510.  
  511. //------------------------------------------------------------------------------
  512. // ODFrame: AcquireWindow
  513. //------------------------------------------------------------------------------
  514.  
  515. SOM_Scope ODWindow*  SOMLINK ODFrameAcquireWindow(ODFrame *somSelf, Environment *ev)
  516. {
  517.     ODFrameData *somThis = ODFrameGetData(somSelf);
  518.     ODFrameMethodDebug("ODFrame","AcquireWindow");
  519.  
  520.     CHECKVALID(kODNULL);
  521.     
  522.     ODWindow* window = kODNULL;    ODVolatile(window);
  523.  
  524.     SOM_TRY
  525.         if ( _fWindow )
  526.         {
  527.             window = _fWindow;
  528.             ODAcquireObject(ev, _fWindow);
  529.         }
  530.         else if ( !_fIsRoot )
  531.         {
  532.             TempODFrame containingFrame = somSelf->AcquireContainingFrame(ev);
  533.             window = containingFrame->AcquireWindow(ev); // bumps ref count for caller
  534.         }
  535.     SOM_CATCH_ALL
  536.         window = kODNULL;
  537.     SOM_ENDTRY
  538.     return window;
  539. }
  540.  
  541. SOM_Scope void  SOMLINK ODFrameSetWindow(ODFrame *somSelf, Environment *ev,
  542.         ODWindow* window)
  543. {
  544.     ODFrameData *somThis = ODFrameGetData(somSelf);
  545.     ODFrameMethodDebug("ODFrame","SetWindow");
  546.  
  547.     CHECKVALID( VOID );
  548.  
  549.     SOM_TRY
  550.         if ( !_fIsRoot )
  551.             THROW(kODErrNotRootFrame);
  552.     
  553.         ODAcquireObject(ev, window);
  554.         ODReleaseObject(ev, _fWindow);
  555.         _fWindow = window;
  556.     SOM_CATCH_ALL
  557.     SOM_ENDTRY
  558. }
  559.  
  560. //------------------------------------------------------------------------------
  561. // ODFrame: GetPartInfo
  562. //------------------------------------------------------------------------------
  563.  
  564. SOM_Scope ODInfoType  SOMLINK ODFrameGetPartInfo(ODFrame *somSelf, Environment *ev)
  565. {
  566.     ODFrameData *somThis = ODFrameGetData(somSelf);
  567.     ODFrameMethodDebug("ODFrame","GetPartInfo");
  568.  
  569.     CHECKVALID(kODNULL);
  570.     
  571.     if ( _fPart == kODNULL )    // part has not been internalized yet
  572.     {
  573.         SOM_TRY
  574.             somSelf->AcquirePart(ev)->Release(ev);    // force internalization of partInfo
  575.         SOM_CATCH_ALL
  576.         SOM_ENDTRY
  577.     }
  578.  
  579.     return _fPartInfo;
  580. }
  581.  
  582. SOM_Scope void  SOMLINK ODFrameSetPartInfo(ODFrame *somSelf, Environment *ev,
  583.         ODInfoType partInfo)
  584. {
  585.     ODFrameData *somThis = ODFrameGetData(somSelf);
  586.     ODFrameMethodDebug("ODFrame","SetPartInfo");
  587.  
  588.     CHECKVALID( VOID );
  589.  
  590.     _fPartInfo = partInfo;
  591. }
  592.     
  593. //------------------------------------------------------------------------------
  594. // ODFrame: GetViewType
  595. //------------------------------------------------------------------------------
  596.  
  597. SOM_Scope ODTypeToken  SOMLINK ODFrameGetViewType(ODFrame *somSelf, Environment *ev)
  598. {
  599.     ODFrameData *somThis = ODFrameGetData(somSelf);
  600.     ODFrameMethodDebug("ODFrame","GetViewType");
  601.  
  602.     CHECKVALID(kODNULL);
  603.     
  604.     return _fViewType;
  605. }
  606.  
  607. SOM_Scope void  SOMLINK ODFrameSetViewType(ODFrame *somSelf, Environment *ev,
  608.         ODTypeToken viewType)
  609. {
  610.     ODFrameData *somThis = ODFrameGetData(somSelf);
  611.     ODFrameMethodDebug("ODFrame","SetViewType");
  612.  
  613.     CHECKVALID( VOID );
  614.  
  615.     SOM_TRY
  616.         if ( kODNULL == viewType )
  617.             THROW(kODErrIllegalNullTokenInput);
  618.     
  619.         if ( _fViewType != viewType )
  620.         {
  621.             _fViewType = viewType;
  622.     
  623.             somSelf->SetDirty(ev, kViewTypeDirty);
  624.         }
  625.     SOM_CATCH_ALL
  626.     SOM_ENDTRY
  627. }
  628.  
  629. SOM_Scope void  SOMLINK ODFrameChangeViewType(ODFrame *somSelf, Environment *ev,
  630.         ODTypeToken viewType)
  631. {
  632.     ODFrameData *somThis = ODFrameGetData(somSelf);
  633.     ODFrameMethodDebug("ODFrame","ChangeViewType");
  634.  
  635.     CHECKVALID( VOID );
  636.  
  637.     SOM_TRY
  638.         if ( kODNULL == viewType )
  639.             THROW(kODErrIllegalNullTokenInput);
  640.     
  641.         if ( viewType != _fViewType )
  642.         {
  643.             _fViewType = viewType;
  644.             
  645.             TempODPart tempPart = somSelf->AcquirePart(ev);
  646.             tempPart->ViewTypeChanged(ev, somSelf);
  647.         
  648.             somSelf->SetDirty(ev, kViewTypeDirty);
  649.         }
  650.     SOM_CATCH_ALL
  651.     SOM_ENDTRY
  652. }
  653.  
  654. //------------------------------------------------------------------------------
  655. // ODFrame: GetPresentation
  656. //------------------------------------------------------------------------------
  657.  
  658. SOM_Scope ODTypeToken  SOMLINK ODFrameGetPresentation(ODFrame *somSelf, Environment *ev)
  659. {
  660.     ODFrameData *somThis = ODFrameGetData(somSelf);
  661.     ODFrameMethodDebug("ODFrame","GetPresentation");
  662.  
  663.     CHECKVALID(kODNULL);
  664.     
  665.     return _fPresentation;
  666. }
  667.  
  668. SOM_Scope void  SOMLINK ODFrameSetPresentation(ODFrame *somSelf, Environment *ev,
  669.         ODTypeToken presentation)
  670. {
  671.     ODFrameData *somThis = ODFrameGetData(somSelf);
  672.     ODFrameMethodDebug("ODFrame","SetPresentation");
  673.  
  674.     CHECKVALID( VOID );
  675.     
  676.     SOM_TRY
  677.         if ( kODNULL == presentation )
  678.             THROW(kODErrIllegalNullTokenInput);
  679.     
  680.         if ( _fPresentation != presentation )
  681.         {
  682.             _fPresentation = presentation;
  683.         
  684.             somSelf->SetDirty(ev, kPresentationDirty);
  685.         }
  686.     SOM_CATCH_ALL
  687.     SOM_ENDTRY
  688. }
  689.  
  690. SOM_Scope void  SOMLINK ODFrameChangePresentation(ODFrame *somSelf, Environment *ev,
  691.         ODTypeToken presentation)
  692. {
  693.     ODFrameData *somThis = ODFrameGetData(somSelf);
  694.     ODFrameMethodDebug("ODFrame","ChangePresentation");
  695.  
  696.     CHECKVALID( VOID );
  697.     
  698.     SOM_TRY
  699.         if ( kODNULL == presentation )
  700.             THROW(kODErrIllegalNullTokenInput);
  701.     
  702.         if ( _fPresentation != presentation )
  703.         {
  704.             _fPresentation = presentation;
  705.  
  706.             TempODPart tempPart = somSelf->AcquirePart(ev);
  707.             tempPart->PresentationChanged(ev, somSelf);
  708.         
  709.             somSelf->SetDirty(ev, kPresentationDirty);
  710.         }
  711.     SOM_CATCH_ALL
  712.     SOM_ENDTRY
  713. }
  714.  
  715. //------------------------------------------------------------------------------
  716. // ODFrame: GetFrameGroup
  717. //------------------------------------------------------------------------------
  718.  
  719. SOM_Scope ODULong  SOMLINK ODFrameGetFrameGroup(ODFrame *somSelf, Environment *ev)
  720. {
  721.     ODFrameData *somThis = ODFrameGetData(somSelf);
  722.     ODFrameMethodDebug("ODFrame","GetFrameGroup");
  723.  
  724.     CHECKVALID(0);
  725.     
  726.     return _fFrameGroup;
  727. }
  728.  
  729. SOM_Scope void  SOMLINK ODFrameSetFrameGroup(ODFrame *somSelf, Environment *ev,
  730.         ODULong groupID)
  731. {
  732.     ODFrameData *somThis = ODFrameGetData(somSelf);
  733.     ODFrameMethodDebug("ODFrame","SetFrameGroup");
  734.  
  735.     CHECKVALID( VOID );
  736.     
  737.     SOM_TRY
  738.         if ( groupID != _fFrameGroup )
  739.         {
  740.             _fFrameGroup = groupID;
  741.         
  742.             somSelf->SetDirty(ev, kFrameGroupDirty);
  743.         }
  744.     SOM_CATCH_ALL
  745.     SOM_ENDTRY
  746. }
  747.  
  748. //------------------------------------------------------------------------------
  749. // ODFrame: GetSequenceNumber
  750. //------------------------------------------------------------------------------
  751.  
  752. SOM_Scope ODULong  SOMLINK ODFrameGetSequenceNumber(ODFrame *somSelf, Environment *ev)
  753. {
  754.     ODFrameData *somThis = ODFrameGetData(somSelf);
  755.     ODFrameMethodDebug("ODFrame","GetSequenceNumber");
  756.  
  757.     CHECKVALID(0);
  758.     
  759.     return _fSequenceNumber;
  760. }
  761.  
  762. SOM_Scope void  SOMLINK ODFrameChangeSequenceNumber(ODFrame *somSelf, Environment *ev,
  763.         ODULong sequenceNumber)
  764. {
  765.     ODFrameData *somThis = ODFrameGetData(somSelf);
  766.     ODFrameMethodDebug("ODFrame","ChangeSequenceNumber");
  767.  
  768.     CHECKVALID( VOID );
  769.     
  770.     SOM_TRY
  771.         if ( sequenceNumber != _fSequenceNumber )
  772.         {
  773.             _fSequenceNumber = sequenceNumber;
  774.         
  775.             somSelf->SetDirty(ev, kSequenceNumberDirty);
  776.         }
  777.     SOM_CATCH_ALL
  778.     SOM_ENDTRY
  779. }
  780.  
  781. //------------------------------------------------------------------------------
  782. // ODFrame: IsRoot
  783. //------------------------------------------------------------------------------
  784.  
  785. SOM_Scope ODBoolean  SOMLINK ODFrameIsRoot(ODFrame *somSelf, Environment *ev)
  786. {
  787.     ODFrameData *somThis = ODFrameGetData(somSelf);
  788.     ODFrameMethodDebug("ODFrame","IsRoot");
  789.  
  790.     CHECKVALID(kODFalse);
  791.     
  792.     return _fIsRoot;
  793. }
  794.  
  795. //------------------------------------------------------------------------------
  796. // ODFrame: IsSubframe
  797. //------------------------------------------------------------------------------
  798.  
  799. SOM_Scope ODBoolean  SOMLINK ODFrameIsSubframe(ODFrame *somSelf, Environment *ev)
  800. {
  801.     ODFrameData *somThis = ODFrameGetData(somSelf);
  802.     ODFrameMethodDebug("ODFrame","IsSubframe");
  803.  
  804.     CHECKVALID(kODFalse);
  805.     
  806.     return _fIsSubframe;
  807. }
  808.  
  809. SOM_Scope void  SOMLINK ODFrameSetSubframe(ODFrame *somSelf, Environment *ev,
  810.         ODBoolean isSubframe)
  811. {
  812.     ODFrameData *somThis = ODFrameGetData(somSelf);
  813.     ODFrameMethodDebug("ODFrame","SetSubframe");
  814.  
  815.     CHECKVALID( VOID );
  816.     
  817.     SOM_TRY
  818.         if ( isSubframe != _fIsSubframe)
  819.         {
  820.             _fIsSubframe = isSubframe;
  821.         
  822.             somSelf->SetDirty(ev, kFlagsDirty);
  823.         }
  824.     SOM_CATCH_ALL
  825.     SOM_ENDTRY
  826. }
  827.     
  828. //------------------------------------------------------------------------------
  829. // ODFrame: IsOverlaid
  830. //------------------------------------------------------------------------------
  831.  
  832. SOM_Scope ODBoolean  SOMLINK ODFrameIsOverlaid(ODFrame *somSelf, Environment *ev)
  833. {
  834.     ODFrameData *somThis = ODFrameGetData(somSelf);
  835.     ODFrameMethodDebug("ODFrame","IsOverlaid");
  836.  
  837.     CHECKVALID(kODFalse);
  838.     
  839.     return _fIsOverlaid;
  840. }
  841.  
  842. //------------------------------------------------------------------------------
  843. // ODFrame: IsFrozen
  844. //------------------------------------------------------------------------------
  845.  
  846. SOM_Scope ODBoolean  SOMLINK ODFrameIsFrozen(ODFrame *somSelf, Environment *ev)
  847. {
  848.     ODFrameData *somThis = ODFrameGetData(somSelf);
  849.     ODFrameMethodDebug("ODFrame","IsFrozen");
  850.  
  851.     CHECKVALID(kODFalse);
  852.     
  853.     return _fIsFrozen;
  854. }
  855.  
  856. SOM_Scope void  SOMLINK ODFrameSetFrozen(ODFrame *somSelf, Environment *ev,
  857.         ODBoolean isFrozen)
  858. {
  859.     ODFrameData *somThis = ODFrameGetData(somSelf);
  860.     ODFrameMethodDebug("ODFrame","SetFrozen");
  861.  
  862.     CHECKVALID( VOID );
  863.     
  864.     SOM_TRY
  865.         if ( isFrozen != _fIsFrozen)
  866.         {
  867.             _fIsFrozen = isFrozen;
  868.         
  869.             somSelf->SetDirty(ev, kFlagsDirty);
  870.         }
  871.     SOM_CATCH_ALL
  872.     SOM_ENDTRY
  873. }
  874.  
  875. //------------------------------------------------------------------------------
  876. // ODFrame: DoesPropagateEvents
  877. //------------------------------------------------------------------------------
  878.  
  879. SOM_Scope ODBoolean  SOMLINK ODFrameDoesPropagateEvents(ODFrame *somSelf, Environment *ev)
  880. {
  881.     ODFrameData *somThis = ODFrameGetData(somSelf);
  882.     ODFrameMethodDebug("ODFrame","DoesPropagateEvents");
  883.  
  884.     CHECKVALID(kODFalse);
  885.     
  886.     return _fDoesPropagateEvents;
  887. }
  888.  
  889. SOM_Scope void  SOMLINK ODFrameSetPropagateEvents(ODFrame *somSelf, Environment *ev,
  890.         ODBoolean doesPropagateEvents)
  891. {
  892.     ODFrameData *somThis = ODFrameGetData(somSelf);
  893.     ODFrameMethodDebug("ODFrame","SetPropagateEvents");
  894.  
  895.     CHECKVALID( VOID );
  896.     
  897.     if ( doesPropagateEvents != _fDoesPropagateEvents)
  898.         _fDoesPropagateEvents = doesPropagateEvents;
  899. }
  900.     
  901. //------------------------------------------------------------------------------
  902. // ODFrame: IsInLimbo
  903. //------------------------------------------------------------------------------
  904.  
  905. SOM_Scope ODBoolean  SOMLINK ODFrameIsInLimbo(ODFrame *somSelf, Environment *ev)
  906. {
  907.     ODFrameData *somThis = ODFrameGetData(somSelf);
  908.     ODFrameMethodDebug("ODFrame","IsInLimbo");
  909.  
  910.     CHECKVALID(kODFalse);
  911.     
  912.     return _fIsInLimbo;
  913. }
  914.  
  915. SOM_Scope void  SOMLINK ODFrameSetInLimbo(ODFrame *somSelf, Environment *ev,
  916.         ODBoolean isInLimbo)
  917. {
  918.     ODFrameData *somThis = ODFrameGetData(somSelf);
  919.     ODFrameMethodDebug("ODFrame","SetInLimbo");
  920.  
  921.     CHECKVALID( VOID );
  922.     
  923.     if ( isInLimbo != _fIsInLimbo)
  924.         _fIsInLimbo = isInLimbo;
  925. }
  926.     
  927. //------------------------------------------------------------------------------
  928. // ODFrame: AcquirePart
  929. //------------------------------------------------------------------------------
  930.  
  931. SOM_Scope ODPart*  SOMLINK ODFrameAcquirePart(ODFrame *somSelf, Environment *ev)
  932. {
  933.     ODFrameData *somThis = ODFrameGetData(somSelf);
  934.     ODFrameMethodDebug("ODFrame","AcquirePart");
  935.  
  936.     CHECKVALID(kODNULL);
  937.     
  938.     ODFrameFacetIterator* i = kODNULL; ODVolatile(i);
  939.     
  940.     SOM_TRY
  941.         if ( _fPart == kODNULL )    // part has not been internalized yet
  942.         {
  943.             ODStorageUnit     *su = somSelf->GetStorageUnit(ev);
  944.             ODStorageUnitView *suView = kODNULL;
  945.             
  946.             if ( su )
  947.             {
  948.                 _fPart = _fDraft->AcquirePart(ev,
  949.                         ODGetStrongSURefProp(ev, su, kODPropPart, kODStrongStorageUnitRef));
  950.                 ASSERT(_fPart, kODErrAssertionFailed);
  951.                 
  952.                 su->Focus(ev, kODPropPartInfo, kODPosUndefined, kODNULL, 0, kODPosUndefined);
  953.                 {    
  954.                     TempODStorageUnitView suView = su->CreateView(ev);
  955.                     _fPartInfo = (ODInfoType)(_fPart->ReadPartInfo(ev, somSelf, suView));
  956.                 }
  957.                 
  958.                 _fPart->DisplayFrameConnected(ev, somSelf);
  959.  
  960.                 i = somSelf->CreateFacetIterator(ev);
  961.                 for (ODFacet* facet = i->First(ev); i->IsNotComplete(ev); facet = i->Next(ev))
  962.                     _fPart->FacetAdded(ev, facet);
  963.                 ODDeleteObject(i);
  964.             }
  965.         }
  966.         // bump ref count for caller
  967.         ODAcquireObject(ev, _fPart);
  968.     SOM_CATCH_ALL
  969.         ODSafeReleaseObject(_fPart); _fPart = kODNULL;
  970.         ODDeleteObject(i);
  971.     SOM_ENDTRY
  972.     
  973.     return _fPart;
  974. }
  975.     
  976. //------------------------------------------------------------------------------
  977. // ODFrame: ChangePart
  978. //------------------------------------------------------------------------------
  979.  
  980. SOM_Scope void  SOMLINK ODFrameChangePart(ODFrame *somSelf, Environment *ev,
  981.         ODPart* part)
  982. {
  983.     ODFrameData *somThis = ODFrameGetData(somSelf);
  984.     ODFrameMethodDebug("ODFrame","ChangePart");
  985.  
  986.     CHECKVALID( VOID );
  987.     
  988.     SOM_TRY
  989.         if ( !part )
  990.             THROW(kODErrIllegalNullPartInput);
  991.         if ( _fPart == kODNULL )
  992.             somSelf->AcquirePart(ev)->Release(ev);    // force internalization of part
  993.         ASSERT( _fPart, kODErrInvalidPersistentFormat);
  994.         
  995.         ODFrameFacetIterator* i = somSelf->CreateFacetIterator(ev);
  996.         ODFacet* facet = kODNULL;
  997.         
  998.         for (facet = i->First(ev); i->IsNotComplete(ev); facet = i->Next(ev))
  999.             _fPart->FacetRemoved(ev, facet);
  1000.         TRY
  1001.             _fPart->DisplayFrameRemoved(ev, somSelf);
  1002.         CATCH_ALL
  1003.             WARN("Part returned err %d removing frame",ErrorCode());
  1004.             // don't reraise
  1005.         ENDTRY
  1006.     
  1007.         ODAcquireObject(ev, part);
  1008.         ODReleaseObject(ev, _fPart);
  1009.         _fPart = part;
  1010.     
  1011.         _fPart->DisplayFrameAdded(ev, somSelf);
  1012.         for (facet = i->First(ev); i->IsNotComplete(ev); facet = i->Next(ev))
  1013.             _fPart->FacetAdded(ev, facet);
  1014.         
  1015.         delete i;
  1016.     
  1017.         somSelf->SetDirty(ev, kPartDirty);
  1018.     SOM_CATCH_ALL
  1019.     SOM_ENDTRY
  1020. }
  1021.     
  1022. //------------------------------------------------------------------------------
  1023. // ODFrame: FacetAdded
  1024. //------------------------------------------------------------------------------
  1025.  
  1026. SOM_Scope void  SOMLINK ODFrameFacetAdded(ODFrame *somSelf, Environment *ev,
  1027.         ODFacet* facet)
  1028. {
  1029.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1030.     ODFrameMethodDebug("ODFrame","FacetAdded");
  1031.  
  1032.     CHECKVALID( VOID );
  1033.     
  1034.     SOM_TRY
  1035.         TempODPart tempPart = somSelf->AcquirePart(ev);
  1036.         _fFacets->AddLast(facet);
  1037.         tempPart->FacetAdded(ev, facet);
  1038.     SOM_CATCH_ALL
  1039.     SOM_ENDTRY
  1040. }
  1041.  
  1042. //------------------------------------------------------------------------------
  1043. // ODFrame: FacetRemoved
  1044. //------------------------------------------------------------------------------
  1045.  
  1046. SOM_Scope void  SOMLINK ODFrameFacetRemoved(ODFrame *somSelf, Environment *ev,
  1047.         ODFacet* facet)
  1048. {
  1049.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1050.     ODFrameMethodDebug("ODFrame","FacetRemoved");
  1051.  
  1052.     CHECKVALID( VOID );
  1053.     
  1054.     SOM_TRY
  1055.         if ( _fFacets->Contains(facet) )
  1056.         {
  1057.             _fFacets->Remove(facet);
  1058.             TempODPart tempPart = somSelf->AcquirePart(ev);
  1059.             tempPart->FacetRemoved(ev, facet);
  1060.         }
  1061.     SOM_CATCH_ALL
  1062.     SOM_ENDTRY
  1063. }
  1064.  
  1065. //------------------------------------------------------------------------------
  1066. // ODFrame: CreateFacetIterator
  1067. //------------------------------------------------------------------------------
  1068.  
  1069. SOM_Scope ODFrameFacetIterator*  SOMLINK ODFrameCreateFacetIterator(ODFrame *somSelf, Environment *ev)
  1070. {
  1071.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1072.     ODFrameMethodDebug("ODFrame","CreateFacetIterator");
  1073.  
  1074.     ODFrameFacetIterator* iter = kODNULL; ODVolatile(iter);
  1075.  
  1076.     CHECKVALID(kODNULL);
  1077.     
  1078.     SOM_TRY
  1079.         iter = new ODFrameFacetIterator;
  1080.           THROW_IF_NULL(iter);
  1081.         iter->InitFrameFacetIterator(ev, somSelf);
  1082.     SOM_CATCH_ALL
  1083.         ODDeleteObject(iter);
  1084.         iter = kODNULL;
  1085.     SOM_ENDTRY
  1086.     return iter;
  1087. }
  1088.  
  1089. //------------------------------------------------------------------------------
  1090. // ODFrame: CreateShape
  1091. //------------------------------------------------------------------------------
  1092.  
  1093. SOM_Scope ODShape*  SOMLINK ODFrameCreateShape(ODFrame *somSelf, Environment *ev)
  1094. {
  1095.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1096.     ODFrameMethodDebug("ODFrame","CreateShape");
  1097.  
  1098.     CHECKVALID(kODNULL);
  1099.     
  1100.     ODShape *s = kODNULL;  ODVolatile(s);
  1101.     
  1102.     SOM_TRY
  1103.         s = new ODShape;
  1104.         THROW_IF_NULL(s);
  1105.         s->InitShape(ev);
  1106.     SOM_CATCH_ALL
  1107.           ODDeleteObject(s);
  1108.         s = kODNULL;
  1109.     SOM_ENDTRY
  1110.     return s;
  1111. }
  1112.  
  1113. //------------------------------------------------------------------------------
  1114. // ODFrame: AcquireFrameShape
  1115. //------------------------------------------------------------------------------
  1116.  
  1117. SOM_Scope ODShape*  SOMLINK ODFrameAcquireFrameShape(ODFrame *somSelf, Environment *ev,
  1118.         ODCanvas* biasCanvas)
  1119. {
  1120.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1121.     ODFrameMethodDebug("ODFrame","AcquireFrameShape");
  1122.  
  1123.     CHECKVALID(kODNULL);
  1124.     
  1125.     ODShape* s;
  1126.     SOM_TRY
  1127.         s = BiasShapeGet(ev, _fFrameShape, biasCanvas);
  1128.     SOM_CATCH_ALL
  1129.         s = kODNULL;
  1130.     SOM_ENDTRY
  1131.     return s;
  1132. }
  1133.  
  1134. //------------------------------------------------------------------------------
  1135. // ODFrame: ChangeFrameShape
  1136. //------------------------------------------------------------------------------
  1137.  
  1138. SOM_Scope void  SOMLINK ODFrameChangeFrameShape(ODFrame *somSelf, Environment *ev,
  1139.         ODShape* shape, ODCanvas* biasCanvas)
  1140. {
  1141.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1142.     ODFrameMethodDebug("ODFrame","ChangeFrameShape");
  1143.  
  1144.     CHECKVALID( VOID );
  1145.     
  1146.     ODSession* session;
  1147.     ODTypeToken    selectionFocus;
  1148.  
  1149.     SOM_TRY
  1150.         if (shape)
  1151.         {
  1152.             TempODPart tempPart = somSelf->AcquirePart(ev);
  1153.             session = tempPart->GetStorageUnit(ev)->GetSession(ev);
  1154.             selectionFocus = session->Tokenize(ev, kODSelectionFocus);
  1155.     
  1156.             TempODFrame activeFrame = session->GetArbitrator(ev)->AcquireFocusOwner(ev, selectionFocus);
  1157.             if ( ODObjectsAreEqual(ev, somSelf, activeFrame) )
  1158.                 somSelf->InvalidateActiveBorder(ev);
  1159.     
  1160.             ODAcquireObject(ev, shape);
  1161.             ODReleaseObject(ev, _fFrameShape);
  1162.             _fFrameShape = BiasShapeSet(ev, shape, biasCanvas);
  1163.     
  1164.             tempPart->FrameShapeChanged(ev, somSelf);
  1165.         }
  1166.         else
  1167.             THROW(kODErrIllegalNullShapeInput);    // frame's MUST have a frameShape
  1168.     
  1169.         somSelf->SetDirty(ev, kFrameShapeDirty);
  1170.     SOM_CATCH_ALL
  1171.     SOM_ENDTRY
  1172. }
  1173.  
  1174. //------------------------------------------------------------------------------
  1175. // ODFrame: RequestFrameShape
  1176. //------------------------------------------------------------------------------
  1177.  
  1178. SOM_Scope ODShape*  SOMLINK ODFrameRequestFrameShape(ODFrame *somSelf, Environment *ev,
  1179.         ODShape* shape, ODCanvas* biasCanvas)
  1180. {
  1181.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1182.     ODFrameMethodDebug("ODFrame","RequestFrameShape");
  1183.  
  1184.     CHECKVALID(kODNULL);
  1185.     
  1186.     ODShape* s = kODNULL;
  1187.     SOM_TRY
  1188.         TempODFrame containingFrame = somSelf->AcquireContainingFrame(ev);
  1189.         ODSession* session;
  1190.         ODTypeToken    selectionFocus;
  1191.         
  1192.         if ( shape == kODNULL )
  1193.         {
  1194.             THROW(kODErrIllegalNullShapeInput);
  1195.             return kODNULL;
  1196.         }
  1197.     
  1198.         if ( containingFrame )    // root frames can't negotiate
  1199.         {
  1200.             TempODPart containingPart = containingFrame->AcquirePart(ev);
  1201.             BiasShapeSet(ev, shape, biasCanvas);
  1202.             if (containingPart)
  1203.                 shape = containingPart->RequestFrameShape(ev, somSelf, shape);    
  1204.  
  1205.             TempODPart tempPart = somSelf->AcquirePart(ev);
  1206.             session = tempPart->GetStorageUnit(ev)->GetSession(ev);
  1207.             selectionFocus = session->Tokenize(ev, kODSelectionFocus);
  1208.     
  1209.             TempODFrame activeFrame = session->GetArbitrator(ev)->AcquireFocusOwner(ev, selectionFocus);
  1210.             if ( ODObjectsAreEqual(ev, somSelf, activeFrame) )
  1211.                 somSelf->InvalidateActiveBorder(ev);
  1212.     
  1213.             // shape's refcount is already inflated by containing part
  1214.             ODReleaseObject(ev, _fFrameShape);
  1215.             _fFrameShape = shape;
  1216.         }
  1217.     
  1218.         somSelf->SetDirty(ev, kFrameShapeDirty);
  1219.     
  1220.         s = BiasShapeGet(ev, _fFrameShape, biasCanvas);
  1221.     SOM_CATCH_ALL
  1222.         s = kODNULL;
  1223.     SOM_ENDTRY
  1224.     return s;
  1225. }
  1226.  
  1227. //------------------------------------------------------------------------------
  1228. // ODFrame: AcquireUsedShape
  1229. //------------------------------------------------------------------------------
  1230.  
  1231. SOM_Scope ODShape*  SOMLINK ODFrameAcquireUsedShape(ODFrame *somSelf, Environment *ev,
  1232.         ODCanvas* biasCanvas)
  1233. {
  1234.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1235.     ODFrameMethodDebug("ODFrame","AcquireUsedShape");
  1236.  
  1237.     CHECKVALID(kODNULL);
  1238.     
  1239.     ODShape* s;
  1240.     SOM_TRY
  1241.         if ( _fUsedShape )
  1242.             s = BiasShapeGet(ev, _fUsedShape, biasCanvas);
  1243.         else
  1244.             s = ODCopyAndRelease(ev, BiasShapeGet(ev, _fFrameShape, biasCanvas));
  1245.     SOM_CATCH_ALL
  1246.         s = kODNULL;
  1247.     SOM_ENDTRY
  1248.     return s;
  1249. }
  1250.  
  1251. //------------------------------------------------------------------------------
  1252. // ODFrame: ChangeUsedShape
  1253. //------------------------------------------------------------------------------
  1254.  
  1255. SOM_Scope void  SOMLINK ODFrameChangeUsedShape(ODFrame *somSelf, Environment *ev,
  1256.         ODShape* shape, ODCanvas* biasCanvas)
  1257. {
  1258.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1259.     ODFrameMethodDebug("ODFrame","ChangeUsedShape");
  1260.  
  1261.     CHECKVALID( VOID );
  1262.     
  1263.     SOM_TRY
  1264.         TempODFrame containingFrame = somSelf->AcquireContainingFrame(ev);
  1265.         TempODPart containingPart = kODNULL;
  1266.         
  1267.         ODAcquireObject(ev, shape);
  1268.         ODReleaseObject(ev, _fUsedShape);
  1269.         _fUsedShape = BiasShapeSet(ev, shape, biasCanvas);
  1270.     
  1271.         if ( containingFrame )
  1272.         {    containingPart = containingFrame->AcquirePart(ev);
  1273.             if ( containingPart )
  1274.                 containingPart->UsedShapeChanged(ev, somSelf);
  1275.         }
  1276.     SOM_CATCH_ALL
  1277.     SOM_ENDTRY
  1278. }
  1279.  
  1280. //------------------------------------------------------------------------------
  1281. // ODFrame: CreateTransform
  1282. //------------------------------------------------------------------------------
  1283.  
  1284. SOM_Scope ODTransform*  SOMLINK ODFrameCreateTransform(ODFrame *somSelf, Environment *ev)
  1285. {
  1286.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1287.     ODFrameMethodDebug("ODFrame","CreateTransform");
  1288.  
  1289.     CHECKVALID(kODNULL);
  1290.     
  1291.     ODTransform *t = kODNULL;  ODVolatile(t);
  1292.     SOM_TRY
  1293.         t = new ODTransform;
  1294.         THROW_IF_NULL(t);
  1295.         t->InitTransform(ev);
  1296.     SOM_CATCH_ALL
  1297.         ODDeleteObject(t);
  1298.         t = kODNULL;
  1299.     SOM_ENDTRY
  1300.     return t;
  1301. }
  1302.  
  1303. //------------------------------------------------------------------------------
  1304. // ODFrame: AcquireInternalTransform
  1305. //------------------------------------------------------------------------------
  1306.  
  1307. SOM_Scope ODTransform*  SOMLINK ODFrameAcquireInternalTransform(ODFrame *somSelf, Environment *ev,
  1308.         ODCanvas* biasCanvas)
  1309. {
  1310.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1311.     ODFrameMethodDebug("ODFrame","AcquireInternalTransform");
  1312.  
  1313.     CHECKVALID(kODNULL);
  1314.     
  1315.     ODTransform *t;
  1316.     SOM_TRY
  1317.         t = BiasTransformGet(ev, _fInternalTransform, biasCanvas);
  1318.     SOM_CATCH_ALL
  1319.         t = kODNULL;
  1320.     SOM_ENDTRY
  1321.     return t;
  1322. }
  1323.  
  1324. //------------------------------------------------------------------------------
  1325. // ODFrame: ChangeInternalTransform
  1326. //------------------------------------------------------------------------------
  1327.  
  1328. SOM_Scope void  SOMLINK ODFrameChangeInternalTransform(ODFrame *somSelf, Environment *ev,
  1329.         ODTransform* transform, ODCanvas* biasCanvas)
  1330. {
  1331.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1332.     ODFrameMethodDebug("ODFrame","ChangeInternalTransform");
  1333.  
  1334.     CHECKVALID( VOID );
  1335.     
  1336.     ODFrameFacetIterator* i = kODNULL; ODVolatile(i);
  1337.     SOM_TRY
  1338.         if ( transform )
  1339.         {
  1340.             ODAcquireObject(ev, transform);
  1341.             ODReleaseObject(ev, _fInternalTransform);
  1342.             _fInternalTransform = BiasTransformSet(ev, transform, biasCanvas);
  1343.             
  1344.             i = somSelf->CreateFacetIterator(ev);
  1345.             for (ODFacet* facet = i->First(ev); i->IsNotComplete(ev); facet = i->Next(ev))
  1346.                 facet->InternalTransformChanged(ev);
  1347.             delete i;
  1348.         }
  1349.         else
  1350.         {
  1351.             THROW(kODErrIllegalNullTransformInput);
  1352.         }
  1353.     
  1354.         somSelf->SetDirty(ev, kInternalTransformDirty);
  1355.     SOM_CATCH_ALL
  1356.         ODDeleteObject(i);
  1357.     SOM_ENDTRY
  1358. }
  1359.  
  1360. //------------------------------------------------------------------------------
  1361. // ODFrame: GetContentExtent
  1362. //------------------------------------------------------------------------------
  1363.  
  1364. SOM_Scope void  SOMLINK ODFrameGetContentExtent(ODFrame *somSelf, Environment *ev, ODPoint* contentExtent)
  1365. {
  1366.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1367.     ODFrameMethodDebug("ODFrame","GetContentExtent");
  1368.  
  1369.     ODPoint pt(0,0);
  1370.     *contentExtent = pt;
  1371.  
  1372.     CHECKVALID(VOID);
  1373.     
  1374.     *contentExtent = _fContentExtent;
  1375. }
  1376.  
  1377. //------------------------------------------------------------------------------
  1378. // ODFrame: ChangeContentExtent
  1379. //------------------------------------------------------------------------------
  1380.  
  1381. SOM_Scope void  SOMLINK ODFrameChangeContentExtent(ODFrame *somSelf, Environment *ev,
  1382.         ODPoint* contentExtent)
  1383. {
  1384.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1385.     ODFrameMethodDebug("ODFrame","ChangeContentExtent");
  1386.  
  1387.     CHECKVALID( VOID );
  1388.     
  1389.     ODFrameFacetIterator* i = kODNULL; ODVolatile(i);
  1390.     SOM_TRY
  1391.         _fContentExtent = *contentExtent;
  1392.         
  1393.         // compute biasTransform of each facet's canvas
  1394.         i = somSelf->CreateFacetIterator(ev);    
  1395.         for (ODFacet* facet = i->First(ev); i->IsNotComplete(ev); facet = i->Next(ev))
  1396.         {
  1397.             if ( facet->HasCanvas(ev) )
  1398.                 facet->GetCanvas(ev)->ComputeBiasTransform(ev);
  1399.         }
  1400.         delete i;
  1401.     SOM_CATCH_ALL
  1402.         ODDeleteObject(i);
  1403.     SOM_ENDTRY
  1404. }
  1405.  
  1406. //------------------------------------------------------------------------------
  1407. // ODFrame: IsDroppable
  1408. //------------------------------------------------------------------------------
  1409.  
  1410. SOM_Scope ODBoolean  SOMLINK ODFrameIsDroppable(ODFrame *somSelf, Environment *ev)
  1411. {
  1412.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1413.     ODFrameMethodDebug("ODFrame","IsDroppable");
  1414.  
  1415.     CHECKVALID(kODFalse);
  1416.     
  1417.     return _fIsDroppable;
  1418. }
  1419.  
  1420. SOM_Scope void  SOMLINK ODFrameSetDroppable(ODFrame *somSelf, Environment *ev,
  1421.         ODBoolean isDroppable)
  1422. {
  1423.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1424.     ODFrameMethodDebug("ODFrame","SetDroppable");
  1425.  
  1426.     CHECKVALID( VOID );
  1427.     
  1428.     _fIsDroppable = isDroppable;
  1429. }
  1430.  
  1431. //------------------------------------------------------------------------------
  1432. // ODFrame: IsDragging
  1433. //------------------------------------------------------------------------------
  1434.  
  1435. SOM_Scope ODBoolean  SOMLINK ODFrameIsDragging(ODFrame *somSelf, Environment *ev)
  1436. {
  1437.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1438.     ODFrameMethodDebug("ODFrame","IsDragging");
  1439.  
  1440.     CHECKVALID(kODFalse);
  1441.     
  1442.     return _fIsDragging;
  1443. }
  1444.  
  1445. //------------------------------------------------------------------------------
  1446. // ODFrame: SetDragging
  1447. //------------------------------------------------------------------------------
  1448.  
  1449. SOM_Scope void  SOMLINK ODFrameSetDragging(ODFrame *somSelf, Environment *ev,
  1450.         ODBoolean isDragging)
  1451. {
  1452.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1453.     ODFrameMethodDebug("ODFrame","SetDragging");
  1454.  
  1455.     CHECKVALID( VOID );
  1456.     
  1457.     _fIsDragging = isDragging;
  1458. }
  1459.  
  1460. //------------------------------------------------------------------------------
  1461. // ODFrame: ContentUpdated
  1462. //------------------------------------------------------------------------------
  1463.  
  1464. SOM_Scope void  SOMLINK ODFrameContentUpdated(ODFrame *somSelf, Environment *ev,
  1465.         ODUpdateID change)
  1466. {
  1467.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1468.     ODFrameMethodDebug("ODFrame","ContentUpdated");
  1469.  
  1470.     CHECKVALID( VOID );
  1471.     
  1472.     SOM_TRY
  1473.         TempODFrame embeddedFrame = somSelf;
  1474.         TempODFrame containingFrame = somSelf->AcquireContainingFrame(ev);
  1475.         
  1476.         embeddedFrame->Acquire(ev); // will be released in loop below
  1477.         while ( containingFrame != kODNULL )
  1478.         {
  1479.             TempODPart containingPart = containingFrame->AcquirePart(ev);
  1480.             containingPart->EmbeddedFrameUpdated(ev, embeddedFrame, change);
  1481.             ODReleaseObject(ev, embeddedFrame);
  1482.             embeddedFrame = (ODFrame*) containingFrame; // do not bitwise copy!
  1483.             containingFrame = kODNULL; // avoid double Release in case following fails
  1484.             containingFrame = embeddedFrame->AcquireContainingFrame(ev);
  1485.         }
  1486.         ODReleaseObject(ev, embeddedFrame);
  1487.     SOM_CATCH_ALL
  1488.     SOM_ENDTRY
  1489. }
  1490.  
  1491. //------------------------------------------------------------------------------
  1492. // ODFrame: ChangeLinkStatus
  1493. //------------------------------------------------------------------------------
  1494.  
  1495. SOM_Scope void  SOMLINK ODFrameChangeLinkStatus(ODFrame *somSelf, Environment *ev,
  1496.         ODLinkStatus status)
  1497. {
  1498.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1499.     ODFrameMethodDebug("ODFrame","ChangeLinkStatus");
  1500.  
  1501.     CHECKVALID( VOID );
  1502.     
  1503.     SOM_TRY
  1504.         ODLinkStatus newStatus = _fLinkStatus;
  1505.         ODLinkStatus cfStatus = kODNotInLink;
  1506.  
  1507.         TempODFrame containingFrame = somSelf->AcquireContainingFrame(ev);
  1508.         if ( containingFrame == kODNULL )
  1509.         {
  1510.             // Loop looking for a containing frame in case the source frame
  1511.             // turns out to be the root frame of another window [cc]
  1512.             TempODFrame sourceFrame = somSelf;
  1513.             sourceFrame->Acquire(ev); // because it will be Released below
  1514.             do
  1515.             {
  1516.                 TempODWindow tempWindow = sourceFrame->AcquireWindow(ev);
  1517.                 sourceFrame = tempWindow->AcquireSourceFrame(ev);
  1518.                 if ( sourceFrame )
  1519.                 {
  1520.                     containingFrame = sourceFrame->AcquireContainingFrame(ev);
  1521.                 }
  1522.             }
  1523.             while ( (containingFrame == kODNULL) && (sourceFrame != kODNULL) );
  1524.         }
  1525.  
  1526.         if ( containingFrame )
  1527.         {
  1528.             cfStatus = containingFrame->GetLinkStatus(ev);
  1529.         }
  1530.  
  1531.         if ( (status != kODNotInLink)
  1532.                 && (status != kODInLinkSource)
  1533.                 && (status != kODInLinkDestination) )
  1534.             THROW(kODErrInvalidLinkStatus);        
  1535.         
  1536.         // the logic below will automatically fix the link status of an embedded
  1537.         // frame to be at least as restrictive as the status of its containing frame
  1538.         if ( cfStatus == kODNotInLink )
  1539.         {
  1540.             newStatus = status;
  1541.         }
  1542.         else if ( cfStatus == kODInLinkSource )
  1543.         {
  1544.             if ( status == kODInLinkDestination )
  1545.                 newStatus = kODInLinkDestination;
  1546.             else
  1547.                 newStatus = kODInLinkSource;
  1548.         }
  1549.         else if ( cfStatus == kODInLinkDestination )
  1550.         {
  1551.             newStatus = kODInLinkDestination;
  1552.         }
  1553.         else
  1554.             THROW(kODErrInvalidLinkStatus);        
  1555.         
  1556.         if ( _fLinkStatus != newStatus )
  1557.         {
  1558.             _fLinkStatus = newStatus;
  1559.             TempODPart tempPart = somSelf->AcquirePart(ev);
  1560.             tempPart->LinkStatusChanged(ev, somSelf);
  1561.         }
  1562.     
  1563.         // don't mark draft dirty, just mark property dirty
  1564.         _fDirty |= kLinkStatusDirty;
  1565.     SOM_CATCH_ALL
  1566.     SOM_ENDTRY
  1567. }
  1568.  
  1569. //------------------------------------------------------------------------------
  1570. // ODFrame: GetLinkStatus
  1571. //------------------------------------------------------------------------------
  1572.  
  1573. SOM_Scope ODLinkStatus  SOMLINK ODFrameGetLinkStatus(ODFrame *somSelf, Environment *ev)
  1574. {
  1575.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1576.     ODFrameMethodDebug("ODFrame","GetLinkStatus");
  1577.  
  1578.     CHECKVALID(kODFalse);
  1579.     
  1580.     return _fLinkStatus;
  1581. }
  1582.  
  1583. //------------------------------------------------------------------------------
  1584. // ODFrame: EditInLink
  1585. //------------------------------------------------------------------------------
  1586.  
  1587. SOM_Scope ODBoolean  SOMLINK ODFrameEditInLink(ODFrame *somSelf, Environment *ev)
  1588. {
  1589.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1590.     ODFrameMethodDebug("ODFrame","EditInLink");
  1591.  
  1592.     CHECKVALID(kODFalse);
  1593.     
  1594.     ODBoolean success = kODFalse;    ODVolatile(success);
  1595.  
  1596.     SOM_TRY    
  1597.         if ( _fLinkStatus == kODInLinkDestination )
  1598.         {
  1599.             TempODFrame lastFrame = somSelf;
  1600.             lastFrame->Acquire(ev); // because it will be Released below
  1601.             while ( kODTrue )
  1602.             {
  1603.                 TempODFrame nextFrame = lastFrame->AcquireContainingFrame(ev);
  1604.                 if ( nextFrame == kODNULL )
  1605.                 {
  1606.                     TempODWindow tempWindow = lastFrame->AcquireWindow(ev);
  1607.                     nextFrame = tempWindow->AcquireSourceFrame(ev);
  1608.                 }
  1609.                 if ( nextFrame == kODNULL )
  1610.                     break;
  1611.                 
  1612.                 // the test below should never be true if nextFrame is lastFrame's
  1613.                 // sourceFrame, therefore below nextFrame will always be the
  1614.                 // containing frame of lastFrame
  1615.                 if ( nextFrame->GetLinkStatus(ev) != kODInLinkDestination )
  1616.                 {
  1617.                     TempODPart tempPart = nextFrame->AcquirePart(ev);
  1618.                     success = tempPart->EditInLinkAttempted(ev, lastFrame);
  1619.                     break;
  1620.                 }
  1621.                 else
  1622.                 {
  1623.                     ODReleaseObject(ev, lastFrame);
  1624.                     lastFrame = (ODFrame*) nextFrame; // do not bitwise copy!
  1625.                     nextFrame = kODNULL; // to prevent Release on loop
  1626.                 }
  1627.             }
  1628.         }
  1629.     SOM_CATCH_ALL
  1630.         success = kODFalse;
  1631.     SOM_ENDTRY
  1632.     return success;
  1633. }
  1634.  
  1635. //------------------------------------------------------------------------------
  1636. // ODFrame: Invalidate
  1637. //------------------------------------------------------------------------------
  1638.  
  1639. SOM_Scope void  SOMLINK ODFrameInvalidate(ODFrame *somSelf, Environment *ev,
  1640.         ODShape* invalidShape, ODCanvas* biasCanvas)
  1641. {
  1642.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1643.     ODFrameMethodDebug("ODFrame","Invalidate");
  1644.  
  1645.     CHECKVALID( VOID );
  1646.     
  1647.     ODFrameFacetIterator* i = kODNULL; ODVolatile(i);
  1648.     SOM_TRY
  1649.         i = somSelf->CreateFacetIterator(ev);    
  1650.         for (ODFacet* facet = i->First(ev); i->IsNotComplete(ev); facet = i->Next(ev))
  1651.             facet->Invalidate(ev, invalidShape, biasCanvas);
  1652.         delete i;
  1653.     SOM_CATCH_ALL
  1654.         ODDeleteObject(i);
  1655.     SOM_ENDTRY
  1656. }
  1657.  
  1658. //------------------------------------------------------------------------------
  1659. // ODFrame: Validate
  1660. //------------------------------------------------------------------------------
  1661.  
  1662. SOM_Scope void  SOMLINK ODFrameValidate(ODFrame *somSelf, Environment *ev,
  1663.         ODShape* validShape, ODCanvas* biasCanvas)
  1664. {
  1665.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1666.     ODFrameMethodDebug("ODFrame","Validate");
  1667.  
  1668.     CHECKVALID( VOID );
  1669.     
  1670.     ODFrameFacetIterator* i = kODNULL; ODVolatile(i);
  1671.     SOM_TRY
  1672.         i = somSelf->CreateFacetIterator(ev);    
  1673.         for (ODFacet* facet = i->First(ev); i->IsNotComplete(ev); facet = i->Next(ev))
  1674.             facet->Validate(ev, validShape, biasCanvas);
  1675.         delete i;
  1676.     SOM_CATCH_ALL
  1677.         ODDeleteObject(i);
  1678.     SOM_ENDTRY
  1679. }
  1680.  
  1681.  
  1682. //------------------------------------------------------------------------------
  1683. // ODFrame: InvalidateActiveBorder
  1684. //------------------------------------------------------------------------------
  1685. SOM_Scope void  SOMLINK ODFrameInvalidateActiveBorder(ODFrame *somSelf, Environment *ev)
  1686. {
  1687.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1688.     ODFrameMethodDebug("ODFrame","InvalidateActiveBorder");
  1689.  
  1690.     CHECKVALID( VOID );
  1691.     
  1692.     if ( _fIsRoot )        // don't draw for root frame with subframes
  1693.         return;
  1694.     
  1695.     ODFrameFacetIterator* i = kODNULL; ODVolatile(i);
  1696.     SOM_TRY
  1697.         if ( _fIsSubframe )
  1698.         {
  1699.             // don't draw for subframes. instead, have containingFrame draw
  1700.             TempODFrame containingFrame = somSelf->AcquireContainingFrame(ev);
  1701.             containingFrame->InvalidateActiveBorder(ev);
  1702.         }
  1703.         else
  1704.         {
  1705.             // draw active border on all my facets
  1706.             i = somSelf->CreateFacetIterator(ev);
  1707.             for ( ODFacet* facet = i->First(ev);
  1708.                     i->IsNotComplete(ev);
  1709.                     facet = i->Next(ev) )
  1710.             {
  1711.                 facet->InvalidateActiveBorder(ev);
  1712.             }
  1713.             ODDeleteObject(i);
  1714.         }
  1715.     SOM_CATCH_ALL
  1716.         ODDeleteObject(i);
  1717.     SOM_ENDTRY
  1718. }
  1719.  
  1720. //------------------------------------------------------------------------------
  1721. // ODFrame: DrawActiveBorder
  1722. //------------------------------------------------------------------------------
  1723.  
  1724. SOM_Scope void  SOMLINK ODFrameDrawActiveBorder(ODFrame *somSelf, Environment *ev)
  1725. {
  1726.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1727.     ODFrameMethodDebug("ODFrame","DrawActiveBorder");
  1728.  
  1729.     CHECKVALID( VOID );
  1730.     
  1731.     if ( _fIsRoot )        // don't draw for root frame with subframes
  1732.         return;
  1733.  
  1734.     ODFrameFacetIterator* i = kODNULL; ODVolatile(i);
  1735.     SOM_TRY
  1736.         if ( _fIsSubframe )
  1737.         {
  1738.             // don't draw for subframes. instead, have containingFrame draw
  1739.             TempODFrame containingFrame = somSelf->AcquireContainingFrame(ev);
  1740.             containingFrame->DrawActiveBorder(ev);
  1741.         }
  1742.         else
  1743.         {
  1744.             // draw active border on all my facets
  1745.             i = somSelf->CreateFacetIterator(ev);
  1746.             for ( ODFacet* facet = i->First(ev);
  1747.                     i->IsNotComplete(ev);
  1748.                     facet = i->Next(ev) )
  1749.             {
  1750.                 facet->DrawActiveBorder(ev);
  1751.             }
  1752.             delete i;
  1753.         }
  1754.     SOM_CATCH_ALL
  1755.         ODDeleteObject(i);
  1756.     SOM_ENDTRY
  1757. }
  1758.  
  1759. //------------------------------------------------------------------------------
  1760. // ODFrame: Release
  1761. //------------------------------------------------------------------------------
  1762.  
  1763. SOM_Scope void  SOMLINK ODFrameRelease(ODFrame *somSelf, Environment *ev)
  1764. {
  1765.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1766.     ODFrameMethodDebug("ODFrame","Release");
  1767.  
  1768.     // *DON'T* CHECKVALID - need to be able to release invalid frames
  1769.  
  1770.     SOM_TRY
  1771.         if ( (somSelf->GetRefCount(ev) == 1) &&
  1772.             (_fValidState & kFrameIsRemoved) &&
  1773.             !(_fValidState & kFrameIsInRelease) &&
  1774.             somSelf->GetStorageUnit(ev) )
  1775.         {
  1776.             // remove persistent frames previously removed which are
  1777.             // finally unreferenced
  1778.             _fValidState |= kFrameIsInRelease;
  1779.             _fDraft->RemoveFrame(ev, somSelf);
  1780.         }
  1781.         else
  1782.         {
  1783.             parent_Release(somSelf, ev);
  1784.             if (somSelf->GetRefCount(ev) == 0)
  1785.             {
  1786.                 // only release frames previously closed or non-persistent
  1787.                 _fDraft->ReleaseFrame(ev, somSelf);
  1788.                 _fValidState &= ~kFrameIsInRelease;
  1789.             }
  1790.         }
  1791.     SOM_CATCH_ALL
  1792.     SOM_ENDTRY
  1793. }
  1794.  
  1795. //------------------------------------------------------------------------------
  1796. // ODFrame: Close
  1797. //------------------------------------------------------------------------------
  1798.  
  1799. SOM_Scope void  SOMLINK ODFrameClose(ODFrame *somSelf, Environment *ev)
  1800. {
  1801.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1802.     ODFrameMethodDebug("ODFrame","Close");
  1803.  
  1804.     CHECKVALID( VOID );
  1805.  
  1806.     ODFrameFacetIterator* i = kODNULL; ODVolatile(i);
  1807.  
  1808.     SOM_TRY
  1809.         if ( _fPart ) // if fPart not already internalized, don't force it
  1810.         {
  1811.             i = somSelf->CreateFacetIterator(ev);
  1812.             for (ODFacet* facet = i->First(ev); i->IsNotComplete(ev); facet = i->Next(ev))
  1813.                 _fPart->FacetRemoved(ev, facet);
  1814.             ODDeleteObject(i);
  1815.         
  1816.             TRY
  1817.                 _fPart->DisplayFrameClosed(ev, somSelf);
  1818.             CATCH_ALL
  1819.                 WARN("Part returned err %d closing frame",ErrorCode());
  1820.                 // don't reraise
  1821.             ENDTRY
  1822.             ODReleaseObject(ev,_fPart);
  1823.         }
  1824.         ODReleaseObject(ev, _fContainingFrame);
  1825.         ODReleaseObject(ev, _fWindow);
  1826.         somSelf->Release(ev);
  1827.     SOM_CATCH_ALL
  1828.         ODDeleteObject(i);
  1829.     SOM_ENDTRY
  1830. }
  1831.  
  1832. //------------------------------------------------------------------------------
  1833. // ODFrame: Remove
  1834. //------------------------------------------------------------------------------
  1835.  
  1836. SOM_Scope void  SOMLINK ODFrameRemove(ODFrame *somSelf, Environment *ev)
  1837. {
  1838.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1839.     ODFrameMethodDebug("ODFrame","Remove");
  1840.  
  1841.     CHECKVALID( VOID );
  1842.  
  1843.     ODFrameFacetIterator* i = kODNULL; ODVolatile(i);
  1844.  
  1845.     SOM_TRY
  1846.         if ( _fPart == kODNULL )
  1847.             somSelf->AcquirePart(ev)->Release(ev);    // force internalization of fPart
  1848.  
  1849.         if ( _fFacets->Count() != 0 )
  1850.             THROW(kODErrFrameHasFacets);
  1851.         
  1852.         TRY
  1853.             _fPart->DisplayFrameRemoved(ev, somSelf);
  1854.         CATCH_ALL
  1855.             WARN("Part returned err %d removing frame",ErrorCode());
  1856.             // don't reraise
  1857.         ENDTRY
  1858.         
  1859.         ODReleaseObject(ev, _fPart);
  1860.         ODReleaseObject(ev, _fContainingFrame);
  1861.         ODReleaseObject(ev, _fWindow);
  1862.         
  1863.         if (somSelf->GetRefCount(ev) == 1)
  1864.         {
  1865.             _fDraft->RemoveFrame(ev, somSelf);
  1866.         }
  1867.         else
  1868.         {
  1869.             somSelf->Release(ev);
  1870.             _fValidState = kFrameIsRemoved;
  1871.         }
  1872.     SOM_CATCH_ALL
  1873.         ODDeleteObject(i);
  1874.     SOM_ENDTRY
  1875. }
  1876.  
  1877. //------------------------------------------------------------------------------
  1878. // ODFrame: Purge
  1879. //------------------------------------------------------------------------------
  1880.  
  1881. SOM_Scope ODSize  SOMLINK ODFramePurge(ODFrame *somSelf, Environment *ev,
  1882.         ODSize numBytes)
  1883. {
  1884.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1885.     ODFrameMethodDebug("ODFrame","Purge");
  1886.  
  1887.     // *DON'T* CHECKVALID - still need to purge invalid frames
  1888.  
  1889.     ODSize freed = 0;                    ODVolatile(freed);
  1890.     ODFrameFacetIterator* i = kODNULL;    ODVolatile(i);
  1891.  
  1892.     SOM_TRY
  1893.         // purge geometric objects
  1894.         if ( _fFrameShape != kODNULL )
  1895.             freed += _fFrameShape->Purge(ev, numBytes-freed);
  1896.         if ( _fUsedShape != kODNULL )
  1897.             freed += _fUsedShape->Purge(ev, numBytes-freed);
  1898.         if ( _fInternalTransform != kODNULL )
  1899.             freed += _fInternalTransform->Purge(ev, numBytes-freed);
  1900.         
  1901.         if ( _fValidState == kFrameIsValid )
  1902.         {
  1903.             // purge facets
  1904.             i = new ODFrameFacetIterator;
  1905.             THROW_IF_NULL(i);
  1906.             i->InitFrameFacetIterator(ev, somSelf);
  1907.             for ( ODFacet* facet = i->First(ev);
  1908.                     i->IsNotComplete(ev);
  1909.                     facet = i->Next(ev) )
  1910.             {
  1911.                 freed += facet->Purge(ev, numBytes-freed);
  1912.             }
  1913.             ODDeleteObject(i);
  1914.         }
  1915.         
  1916.         // dh - call parent's purge method
  1917.         freed += parent_Purge(somSelf, ev, numBytes);
  1918.         
  1919.     SOM_CATCH_ALL
  1920.         ODDeleteObject(i);
  1921.         WARN("Error %ld trying to purge in ODFramePurge",ErrorCode());
  1922.         SetErrorCode(kODNoError);        // dh - Eat the exception; Purge should not 
  1923.                                         // propagate it because clients function
  1924.                                         // fine whether memory was purged or not.
  1925.     SOM_ENDTRY
  1926.  
  1927.     return freed;
  1928. }
  1929.  
  1930. //------------------------------------------------------------------------------
  1931. // WriteShapeIfAny  [static]
  1932. //------------------------------------------------------------------------------
  1933.  
  1934. static void
  1935. WriteShapeIfAny( Environment *ev, ODStorageUnit *su, ODShape *shape, ODPropertyName property )
  1936. {
  1937.     if (shape) {
  1938.         su->Focus(ev, property, kODPosUndefined, kODNULL, (ODValueIndex)0, kODPosUndefined);
  1939.          shape->WriteShape(ev, su);
  1940.     } else if (su->Exists(ev, property, kODNULL, 1)) {
  1941.         su->Focus(ev, property, kODPosUndefined, kODNULL, (ODValueIndex)1, kODPosUndefined);
  1942.         su->DeleteValue(ev, su->GetSize(ev));
  1943.     }
  1944. }
  1945.  
  1946. //------------------------------------------------------------------------------
  1947. // ODFrame: Externalize
  1948. //------------------------------------------------------------------------------
  1949.  
  1950. SOM_Scope void  SOMLINK ODFrameExternalize(ODFrame *somSelf, Environment *ev)
  1951. {
  1952.     ODFrameData *somThis = ODFrameGetData(somSelf);
  1953.     ODFrameMethodDebug("ODFrame","Externalize");
  1954.  
  1955.     // *DON'T* CHECKVALID - need to write an "I'm invalid" representation
  1956.  
  1957.     SOM_TRY
  1958.         ODStorageUnit* su = kODNULL;
  1959.         ODSession* session = kODNULL;
  1960.         ODISOStr typeString = kODNULL;
  1961.         
  1962.         su = somSelf->GetStorageUnit(ev);
  1963.         if ( su == kODNULL) return;        // don't externalize non-persistent frames
  1964.         
  1965.         parent_Externalize(somSelf, ev);
  1966.     
  1967.         session = su->GetSession(ev);
  1968.         
  1969.         // if frame is invalid because of removal, delete Part property to
  1970.         // indicate persistently that frame is invalid.
  1971.         if ( _fDirty && _fValidState )
  1972.         {
  1973.             ODSURemoveProperty(ev, su, kODPropPart);
  1974.             ODSURemoveProperty(ev, su, kODPropContainingFrame);
  1975.             _fDirty = kNotDirty;
  1976.             return;
  1977.         }
  1978.     
  1979.         if ( _fDirty & kContainingFrameDirty )
  1980.         {
  1981.             // can't write suRef to non-persistent containingFrame
  1982.             if ( _fContainingFrame && _fContainingFrame->GetStorageUnit(ev) )
  1983.                 ODSetWeakSURefProp(ev, su, kODPropContainingFrame, kODWeakStorageUnitRef, 
  1984.                                     _fContainingFrame->GetStorageUnit(ev)->GetID(ev));
  1985.             else
  1986.             {
  1987.                 if ( ODSUExistsThenFocus(ev, su, kODPropContainingFrame, kODWeakStorageUnitRef) )
  1988.                     su->Remove(ev);
  1989.                 ODSUAddPropValue(ev, su, kODPropContainingFrame, kODWeakStorageUnitRef);
  1990.             }
  1991.         }
  1992.         
  1993.         // geometry
  1994.         
  1995.         // no bias transform needed, already in standard bias
  1996.         ODSURemoveProperty(ev, su, kODPropBiasTransform);
  1997.     
  1998.         if ( _fDirty & kFrameShapeDirty )
  1999.         {
  2000.             su->Focus(ev, kODPropFrameShape, kODPosUndefined, kODNULL, (ODValueIndex)0, kODPosUndefined);
  2001.             _fFrameShape->WriteShape(ev, su);
  2002.         }
  2003.         
  2004.         if ( _fDirty & kInternalTransformDirty )
  2005.         {
  2006.             su->Focus(ev, kODPropInternalTransform, kODPosUndefined, kODNULL, (ODValueIndex)0, kODPosUndefined);
  2007.             _fInternalTransform->WriteTo(ev, su);
  2008.         }
  2009.         
  2010.         // part & partInfo
  2011.         
  2012.         if ( _fDirty & kPartDirty )
  2013.         {
  2014.             ASSERT( _fPart, kODErrInvalidFrame);
  2015.             ODSetStrongSURefProp(ev, su, kODPropPart, kODStrongStorageUnitRef, _fPart->GetID(ev));
  2016.         }
  2017.         
  2018.         // always try to write partInfo, part knows if it's dirty
  2019.         if ( _fPart ) // only have to write partInfo if part has been internalized
  2020.         {
  2021.             su->Focus(ev, kODPropPartInfo, kODPosUndefined, kODNULL, (ODValueIndex)0, kODPosUndefined);
  2022.             TempODStorageUnitView suView = su->CreateView(ev);
  2023.             _fPart->WritePartInfo(ev, (ODInfoType)_fPartInfo, suView);
  2024.         }
  2025.         
  2026.         // viewType & presentation
  2027.         
  2028.         if ( _fDirty & kViewTypeDirty )
  2029.         {
  2030.             if ( (_fViewType != kODNULL) && session->GetType(ev, _fViewType, &typeString) )
  2031.             {
  2032.                 ODSetISOStrProp(ev, su, kODPropViewType, kODISOStr, typeString);
  2033.                 delete typeString; typeString = kODNULL;
  2034.             }
  2035.         }
  2036.         
  2037.         if ( _fDirty & kPresentationDirty )
  2038.         {
  2039.             if ( (_fPresentation != kODNULL) && session->GetType(ev, _fPresentation, &typeString) )
  2040.             {
  2041.                 ODSetISOStrProp(ev, su, kODPropPresentation, kODISOStr, typeString);
  2042.                 delete typeString; typeString = kODNULL;
  2043.             }
  2044.         }
  2045.         
  2046.         if ( _fDirty & kFrameGroupDirty )
  2047.             ODSetULongProp(ev, su, kODPropFrameGroup, kODULong, _fFrameGroup);
  2048.         if ( _fDirty & kSequenceNumberDirty )
  2049.             ODSetULongProp(ev, su, kODPropSequenceNumber, kODULong, _fSequenceNumber);
  2050.         if ( _fDirty & kLinkStatusDirty )
  2051.             ODSetULongProp(ev, su, kODPropLinkStatus, kODULong, _fLinkStatus);
  2052.     
  2053.         if ( _fDirty & kFlagsDirty )
  2054.         {
  2055.             ODSetBooleanProp(ev, su, kODPropIsSubframe, kODBoolean, _fIsSubframe);
  2056.             ODSetBooleanProp(ev, su, kODPropIsOverlaid, kODBoolean, _fIsOverlaid);
  2057.             ODSetBooleanProp(ev, su, kODPropIsFrozen, kODBoolean, _fIsFrozen);
  2058.         }
  2059.     
  2060.         _fDirty = kNotDirty;
  2061.     SOM_CATCH_ALL
  2062.     SOM_ENDTRY
  2063. }
  2064.  
  2065. //------------------------------------------------------------------------------
  2066. // ODFrame: CloneInto
  2067. //------------------------------------------------------------------------------
  2068.  
  2069. SOM_Scope void  SOMLINK ODFrameCloneInto(ODFrame *somSelf, Environment *ev,
  2070.         ODDraftKey key,
  2071.         ODStorageUnit* toSU,
  2072.         ODFrame* scopeFrame)
  2073. {
  2074.     ODFrameData *somThis = ODFrameGetData(somSelf);
  2075.     ODFrameMethodDebug("ODFrame","CloneInto");
  2076.  
  2077.     // *DON'T* CHECKVALID - need to write an "I'm invalid" representation
  2078.  
  2079.     SOM_TRY    
  2080.         if ( kODNULL == toSU ) THROW(kODErrIllegalNullInput);
  2081.     
  2082.         ODStorageUnitID        fromSUID = somSelf->GetID(ev);
  2083.         ODDraft*            fromDraft = _fDraft;
  2084.         ODISOStr            typeString = kODNULL;
  2085.     
  2086.         if (toSU->Exists(ev, kODPropFrameShape, kODNULL, 0) == kODFalse)
  2087.         {
  2088.             parent_CloneInto(somSelf, ev, key, toSU, scopeFrame);
  2089.             
  2090.             // if frame is invalid because of removal, don't write Part
  2091.             // Property to indicate that frame is invalid.
  2092.             if ( _fValidState )
  2093.                 return;
  2094.  
  2095.             if (_fContainingFrame)
  2096.             {
  2097.                 ODID toContainingFrameID = fromDraft->WeakClone(ev, key, _fContainingFrame->GetID(ev), 0, 0);
  2098.                 ODSetWeakSURefProp(ev, toSU, kODPropContainingFrame, kODWeakStorageUnitRef, 
  2099.                                     toContainingFrameID);
  2100.             }
  2101.             
  2102.             toSU->AddProperty(ev, kODPropFrameShape);
  2103.             _fFrameShape->WriteShape(ev, toSU);
  2104.             
  2105.             ODSUAddPropValue(ev, toSU, kODPropInternalTransform, kODTransform);
  2106.             _fInternalTransform->WriteTo(ev, toSU);
  2107.             
  2108.             // part & partInfo
  2109.             
  2110.             if ( _fPart == kODNULL )
  2111.                 somSelf->AcquirePart(ev)->Release(ev); // force internalization of fPart
  2112.  
  2113.             ODID toPartID = fromDraft->Clone(ev, key, _fPart->GetID(ev), 0, (scopeFrame ? scopeFrame->GetID(ev) : 0));
  2114.             ODSetStrongSURefProp(ev, toSU, kODPropPart, kODStrongStorageUnitRef, toPartID);
  2115.         
  2116.             toSU->AddProperty(ev, kODPropPartInfo);
  2117.             {
  2118.                 TempODStorageUnitView suView = toSU->CreateView(ev);
  2119.                 _fPart->ClonePartInfo(ev, key, (ODInfoType)_fPartInfo, suView, scopeFrame);
  2120.             }
  2121.             
  2122.     
  2123.             // Window Properties
  2124.             ODStorageUnit* fromSU = somSelf->GetStorageUnit(ev);
  2125.             if (fromSU && _fIsRoot)
  2126.             {
  2127.                 ODID windowPropsID;
  2128.                 if ((windowPropsID = ODGetStrongSURefProp(ev, fromSU, kODPropWindowProperties, kODStrongStorageUnitRef))
  2129.                     != 0)
  2130.                 {                
  2131.                     ODID toWindowPropsID = fromDraft->Clone(ev, key, windowPropsID, 0, (scopeFrame ? scopeFrame->GetID(ev) : 0));
  2132.                     ODSetStrongSURefProp(ev, toSU, kODPropWindowProperties, kODStrongStorageUnitRef, toWindowPropsID);
  2133.                 }
  2134.             }
  2135.             // viewType & presentation
  2136.             
  2137.             ODSession* session = toSU->GetSession(ev);
  2138.             
  2139.             ASSERT(_fViewType, kODErrInvalidFrame);
  2140.             if ( (_fViewType != kODNULL) && session->GetType(ev, _fViewType, &typeString) )
  2141.             {
  2142.                 ODSetISOStrProp(ev, toSU, kODPropViewType, kODISOStr, typeString);
  2143.                 delete typeString; typeString = kODNULL;
  2144.             }
  2145.         
  2146.             ASSERT(_fPresentation, kODErrInvalidFrame);
  2147.             if ( (_fPresentation != kODNULL) && session->GetType(ev, _fPresentation, &typeString) )
  2148.             {
  2149.                 ODSetISOStrProp(ev, toSU, kODPropPresentation, kODISOStr, typeString);
  2150.                 delete typeString; typeString = kODNULL;
  2151.             }
  2152.         
  2153.             ODSetULongProp(ev, toSU, kODPropFrameGroup, kODULong, _fFrameGroup);
  2154.             ODSetULongProp(ev, toSU, kODPropSequenceNumber, kODULong, _fSequenceNumber);
  2155.             ODSetULongProp(ev, toSU, kODPropLinkStatus, kODULong, _fLinkStatus);
  2156.             ODSetBooleanProp(ev, toSU, kODPropIsSubframe, kODBoolean, _fIsSubframe);
  2157.             ODSetBooleanProp(ev, toSU, kODPropIsOverlaid, kODBoolean, _fIsOverlaid);
  2158.             ODSetBooleanProp(ev, toSU, kODPropIsFrozen, kODBoolean, _fIsFrozen);
  2159.         }
  2160.         else
  2161.         {
  2162.             if ( _fPart == kODNULL )
  2163.                 somSelf->AcquirePart(ev)->Release(ev); // force internalization of fPart
  2164.             ODID toPartID = fromDraft->Clone(ev, key, _fPart->GetID(ev), 0, (scopeFrame ? scopeFrame->GetID(ev) : 0));
  2165.         }
  2166.     SOM_CATCH_ALL
  2167.     SOM_ENDTRY
  2168. }
  2169.  
  2170. //------------------------------------------------------------------------------
  2171. // ODFrame: GetFacets
  2172. //------------------------------------------------------------------------------
  2173.  
  2174. SOM_Scope OrderedCollection*  SOMLINK ODFrameGetFacets(ODFrame *somSelf, Environment *ev)
  2175. {
  2176.     ODFrameData *somThis = ODFrameGetData(somSelf);
  2177.     ODFrameMethodDebug("ODFrame","GetFacets");
  2178.  
  2179.     CHECKVALID(kODNULL);
  2180.  
  2181.     return _fFacets;
  2182. }
  2183.  
  2184. //------------------------------------------------------------------------------
  2185. // ODFrame: PrepareToSwap
  2186. //------------------------------------------------------------------------------
  2187.  
  2188. SOM_Scope void  SOMLINK ODFramePrepareToSwap(ODFrame *somSelf, Environment *ev,
  2189.         ODPart* part)
  2190. {
  2191.     ODFrameData *somThis = ODFrameGetData(somSelf);
  2192.     ODFrameMethodDebug("ODFrame","PrepareToSwap");
  2193.  
  2194.     CHECKVALID( VOID );
  2195.  
  2196.     SOM_TRY
  2197.         ODBoolean swappingMyPart = kODFalse;
  2198.         
  2199.         if ( _fPart )
  2200.             swappingMyPart = ODObjectsAreEqual(ev, part, _fPart);
  2201.         else
  2202.         {
  2203.             ODStorageUnit* su = somSelf->GetStorageUnit(ev);
  2204.             if ( su )
  2205.             {
  2206.                 ODID myPartID = ODGetStrongSURefProp(ev, su, kODPropPart,
  2207.                                                         kODStrongStorageUnitRef);
  2208.                 swappingMyPart = ( part->GetID(ev) == myPartID );
  2209.             }
  2210.         }
  2211.         
  2212.         if ( swappingMyPart )
  2213.         {
  2214.             if ( _fIsRoot && _fWindow )
  2215.             {
  2216.                 _fWindow->Acquire(ev);    // balanced by Release in Close below
  2217.                 _fWindow->Close(ev);
  2218.                 _fWindow = kODNULL;
  2219.             }
  2220.             else
  2221.             {
  2222.                 somSelf->Acquire(ev);  // because Close calls Release on self
  2223.                 somSelf->Close(ev);
  2224.             }
  2225.         }
  2226.     SOM_CATCH_ALL
  2227.     SOM_ENDTRY
  2228. }
  2229.  
  2230.  
  2231. //------------------------------------------------------------------------------
  2232. // ODFrame: SetDirty
  2233. //------------------------------------------------------------------------------
  2234.  
  2235. SOM_Scope void  SOMLINK ODFrameSetDirty(ODFrame *somSelf, Environment *ev,
  2236.                                         ODULong dirtyProperty)
  2237. {
  2238.     ODFrameData *somThis = ODFrameGetData(somSelf);
  2239.     ODFrameMethodDebug("ODFrame","SetDirty");
  2240.  
  2241.     SOM_TRY
  2242.         if ( somSelf->GetStorageUnit(ev) ) // don't set non-persistent frames dirty
  2243.         {
  2244.             _fDirty |= dirtyProperty;
  2245.             if (HAS_WRITE_ACCESS(_fDraft->GetPermissions(ev)))
  2246.             {
  2247.                 _fDraft->SetChangedFromPrev(ev);
  2248.             }
  2249.         }
  2250.     SOM_CATCH_ALL
  2251.     SOM_ENDTRY
  2252. }
  2253.  
  2254. //------------------------------------------------------------------------------
  2255. // ODFrame: CommonInitFrame
  2256. //------------------------------------------------------------------------------
  2257.  
  2258. SOM_Scope void  SOMLINK ODFrameCommonInitFrame(ODFrame *somSelf, Environment *ev)
  2259. {
  2260.     ODFrameData *somThis = ODFrameGetData(somSelf);
  2261.     ODFrameMethodDebug("ODFrame","CommonInitFrame");
  2262.  
  2263.     SOM_TRY
  2264.         _fFacets = new OrderedCollection;
  2265.           THROW_IF_NULL(_fFacets);
  2266.     SOM_CATCH_ALL
  2267.     SOM_ENDTRY
  2268. }
  2269.  
  2270. //------------------------------------------------------------------------------
  2271. // ODFrame: InitFrame
  2272. //------------------------------------------------------------------------------
  2273. SOM_Scope void  SOMLINK ODFrameInitFrame(ODFrame *somSelf, Environment *ev,
  2274.         
  2275.                 ODStorageUnit*    storageUnit,
  2276.                 ODFrame*         containingFrame,
  2277.                 ODShape*         frameShape,
  2278.                 ODCanvas*        biasCanvas,
  2279.                 ODPart*         part,
  2280.                 ODTypeToken        viewType,
  2281.                 ODTypeToken        presentation,
  2282.                 ODBoolean        isSubframe,
  2283.                 ODBoolean         isOverlaid)
  2284. {
  2285.     ODFrameData *somThis = ODFrameGetData(somSelf);
  2286.     ODFrameMethodDebug("ODFrame","InitFrame");
  2287.  
  2288.     /* Moved from somInit. SOM itself sets fields to zero
  2289.     _fDraft             = kODNULL;
  2290.     _fNPID                = 0;
  2291.     _fDirty                = kNotDirty;
  2292.  
  2293.     _fContainingFrame     = kODNULL;
  2294.     _fWindow             = kODNULL;
  2295.  
  2296.     _fFrameShape        = (ODShape*) kODNULL;
  2297.     _fUsedShape            = (ODShape*) kODNULL;
  2298.  
  2299.     _fInternalTransform    = (ODTransform*) kODNULL;    
  2300.  
  2301.     _fFacets            = kODNULL;
  2302.  
  2303.     _fPart                = kODNULL;
  2304.     _fPartInfo            = (ODInfoType) kODNULL;
  2305.     _fViewType            = (ODTypeToken) 0;
  2306.     _fPresentation        = (ODTypeToken) 0;
  2307.  
  2308.     _fFrameGroup        = 0;
  2309.     _fSequenceNumber    = 0;
  2310.  
  2311.     _fLinkStatus        = kODNotInLink;
  2312.     _fIsRoot            = kODFalse;
  2313.     _fIsSubframe         = kODFalse;
  2314.     _fIsOverlaid          = kODFalse;
  2315.     _fIsFrozen             = kODFalse;
  2316.     _fIsDroppable         = kODFalse;
  2317.     _fIsDragging         = kODFalse;
  2318.     _fDoesPropagateEvents =    kODFalse;
  2319.     */
  2320.     _fDirty                = kNotDirty;
  2321.     _fLinkStatus        = kODNotInLink;
  2322.     _fValidState        = kFrameIsValid;
  2323.     
  2324.     // *DON'T* CHECKVALID - new frames will never be invalid
  2325.     
  2326.     SOM_TRY
  2327.         if ( kODNULL == storageUnit )    THROW(kODErrIllegalNullStorageUnitInput);
  2328.         if ( kODNULL == frameShape    )    THROW(kODErrIllegalNullShapeInput);
  2329.         if ( kODNULL == part )            THROW(kODErrIllegalNullPartInput);
  2330.         if ( kODNULL == viewType )        THROW(kODErrIllegalNullTokenInput);
  2331.         if ( kODNULL == presentation )    THROW(kODErrIllegalNullTokenInput);
  2332.     
  2333.         // check for recursive embedding
  2334.         if ( (containingFrame != kODNULL) && !isSubframe )
  2335.         {
  2336.             TempODFrame tempFrame = containingFrame;
  2337.             tempFrame->Acquire(ev);   // because it will be released below
  2338.             while ( tempFrame )
  2339.             {
  2340.                 TempODPart tempPart = tempFrame->AcquirePart(ev);
  2341.                 if (tempPart == part)
  2342.                     THROW(kODErrIllegalRecursiveEmbedding);
  2343.                 ODFrame* spam = tempFrame;
  2344.                 TempODFrame oldFrame = spam;
  2345.                 tempFrame = kODNULL; // to avoid double Release if following fails
  2346.                 tempFrame = oldFrame->AcquireContainingFrame(ev);
  2347.             }
  2348.         }
  2349.         
  2350.         somSelf->InitPersistentObject(ev, storageUnit);
  2351.         _fDraft = storageUnit->GetDraft(ev);
  2352.         
  2353.         _fContainingFrame = containingFrame;
  2354.         ODAcquireObject(ev, _fContainingFrame);
  2355.     
  2356.         _fFrameShape = BiasShapeSet(ev, frameShape, biasCanvas);
  2357.         ODAcquireObject(ev, _fFrameShape);
  2358.     
  2359.         _fInternalTransform    = somSelf->CreateTransform(ev);
  2360.         _fContentExtent        = ODPoint(0,0);
  2361.     
  2362.         _fViewType        = viewType;
  2363.         _fPresentation    = presentation;
  2364.         _fIsRoot        = (containingFrame == kODNULL);
  2365.         _fIsSubframe    = isSubframe;
  2366.         _fIsOverlaid     = isOverlaid;
  2367.     
  2368.         somSelf->CommonInitFrame(ev);
  2369.         
  2370.         ODSUAddPropValue(ev, storageUnit, kODPropContainingFrame, kODWeakStorageUnitRef);
  2371.         ODSUAddPropValue(ev, storageUnit, kODPropFrameShape, kODPolygon);
  2372.         ODSUAddPropValue(ev, storageUnit, kODPropInternalTransform, kODTransform);
  2373.         ODSUAddPropValue(ev, storageUnit, kODPropPart, kODStrongStorageUnitRef);
  2374.     //    ODSUAddPropValue(ev, storageUnit, kODPropPartInfo, kODPartInfo);
  2375.         ODSUAddPropValue(ev, storageUnit, kODPropViewType, kODISOStr);
  2376.         ODSUAddPropValue(ev, storageUnit, kODPropPresentation, kODISOStr);
  2377.         ODSUAddPropValue(ev, storageUnit, kODPropFrameGroup, kODULong);
  2378.         ODSUAddPropValue(ev, storageUnit, kODPropSequenceNumber, kODULong);
  2379.         ODSUAddPropValue(ev, storageUnit, kODPropLinkStatus, kODULong);
  2380.         ODSUAddPropValue(ev, storageUnit, kODPropIsSubframe, kODBoolean);
  2381.         ODSUAddPropValue(ev, storageUnit, kODPropIsOverlaid, kODBoolean);
  2382.         ODSUAddPropValue(ev, storageUnit, kODPropIsFrozen, kODBoolean);
  2383.     
  2384.         _fPart = part;
  2385.         ODAcquireObject(ev, _fPart);
  2386.         _fPart->DisplayFrameAdded(ev, somSelf);
  2387.             
  2388.         somSelf->SetDirty(ev, kAllDirty);
  2389.     SOM_CATCH_ALL
  2390.     SOM_ENDTRY
  2391. }
  2392.  
  2393. //------------------------------------------------------------------------------
  2394. // ReadAndAcquireShapeIfAny  [static]
  2395. //------------------------------------------------------------------------------
  2396.  
  2397. static ODShape* // DMc refcount - include "acquire" in function name:
  2398. ReadAndAcquireShapeIfAny( Environment *ev, ODStorageUnit *su, ODPropertyName property )
  2399. {
  2400.     ODShape* shape = kODNULL;
  2401.     if( su->Exists(ev, property, kODNULL, 0) ) {
  2402.         shape= new ODShape;
  2403.           THROW_IF_NULL(shape);
  2404.         TRY{
  2405.             shape->InitShape(ev);
  2406.             su->Focus(ev, property, kODPosUndefined, kODNULL, 0, kODPosUndefined);
  2407.             shape->ReadShape(ev, su);
  2408.         }CATCH_ALL{
  2409.             delete shape;
  2410.             RERAISE;
  2411.         }ENDTRY
  2412.     }
  2413.     return shape;
  2414. }
  2415.  
  2416. //------------------------------------------------------------------------------
  2417. // ReadAndAcquireTransformIfAny  [static]
  2418. //------------------------------------------------------------------------------
  2419.  
  2420. static ODTransform* // DMc refcount - include "acquire" in function name:
  2421. ReadAndAcquireTransformIfAny( Environment *ev, ODStorageUnit *su, ODPropertyName property )
  2422. {
  2423.     ODTransform* transform = kODNULL;
  2424.     if( su->Exists(ev, property, kODNULL, 0) ) {
  2425.         transform= new ODTransform;
  2426.           THROW_IF_NULL(transform);
  2427.         TRY{
  2428.             transform->InitTransform(ev);
  2429.             su->Focus(ev, property, kODPosUndefined, kODNULL, 0, kODPosUndefined);
  2430.             transform->ReadFrom(ev, su);
  2431.         }CATCH_ALL{
  2432.             delete transform;
  2433.             RERAISE;
  2434.         }ENDTRY
  2435.     }
  2436.     return transform;
  2437. }
  2438.  
  2439. //------------------------------------------------------------------------------
  2440. // ODFrame: InitFrameFromStorage
  2441. //------------------------------------------------------------------------------
  2442.  
  2443. SOM_Scope void  SOMLINK ODFrameInitFrameFromStorage(ODFrame *somSelf, Environment *ev,
  2444.         ODStorageUnit*    storageUnit)
  2445. {
  2446.     ODFrameData *somThis = ODFrameGetData(somSelf);
  2447.     ODFrameMethodDebug("ODFrame","InitFrameFromStorage");
  2448.  
  2449.     /* Moved from somInit. SOM itself sets fields to zero
  2450.     _fDraft             = kODNULL;
  2451.     _fNPID                = 0;
  2452.     _fDirty                = kNotDirty;
  2453.  
  2454.     _fContainingFrame     = kODNULL;
  2455.     _fWindow             = kODNULL;
  2456.  
  2457.     _fFrameShape        = (ODShape*) kODNULL;
  2458.     _fUsedShape            = (ODShape*) kODNULL;
  2459.  
  2460.     _fInternalTransform    = (ODTransform*) kODNULL;    
  2461.  
  2462.     _fFacets            = kODNULL;
  2463.  
  2464.     _fPart                = kODNULL;
  2465.     _fPartInfo            = (ODInfoType) kODNULL;
  2466.     _fViewType            = (ODTypeToken) 0;
  2467.     _fPresentation        = (ODTypeToken) 0;
  2468.  
  2469.     _fFrameGroup        = 0;
  2470.     _fSequenceNumber    = 0;
  2471.  
  2472.     _fLinkStatus        = kODNotInLink;
  2473.     _fIsRoot            = kODFalse;
  2474.     _fIsSubframe         = kODFalse;
  2475.     _fIsOverlaid          = kODFalse;
  2476.     _fIsFrozen             = kODFalse;
  2477.     _fIsDroppable         = kODFalse;
  2478.     _fIsDragging         = kODFalse;
  2479.     _fDoesPropagateEvents =    kODFalse;
  2480.     */
  2481.     _fDirty                = kNotDirty;
  2482.     _fLinkStatus        = kODNotInLink;
  2483.     _fValidState        = kFrameIsValid;
  2484.  
  2485.     // *DON'T* CHECKVALID - need to read an "I'm invalid" representation
  2486.     
  2487.     SOM_TRY
  2488.         if (!storageUnit)
  2489.             THROW(kODErrIllegalNullStorageUnitInput);
  2490.             
  2491.         somSelf->InitPersistentObjectFromStorage(ev, storageUnit);
  2492.         _fDraft = storageUnit->GetDraft(ev);
  2493.     
  2494.     // mark this frame as invalid/removed if it was externalized without a part
  2495.     if ( !storageUnit->Exists(ev, kODPropPart, kODStrongStorageUnitRef, 0) )
  2496.     {
  2497.         _fValidState = kFrameIsRemoved;
  2498.         _fDirty = kNotDirty;
  2499.         return;
  2500.     }
  2501.     
  2502.         ASSERT(storageUnit->Exists(ev, kODPropFrameShape, kODPolygon, 0), kODErrInvalidPersistentFormat);
  2503.         ASSERT(storageUnit->Exists(ev, kODPropInternalTransform, kODTransform, 0), kODErrInvalidPersistentFormat);
  2504.         ASSERT(storageUnit->Exists(ev, kODPropViewType, kODISOStr, 0), kODErrInvalidPersistentFormat);
  2505.         ASSERT(storageUnit->Exists(ev, kODPropPresentation, kODISOStr, 0), kODErrInvalidPersistentFormat);
  2506.         ASSERT(storageUnit->Exists(ev, kODPropFrameGroup, kODULong, 0), kODErrInvalidPersistentFormat);
  2507.         ASSERT(storageUnit->Exists(ev, kODPropSequenceNumber, kODULong, 0), kODErrInvalidPersistentFormat);
  2508.         ASSERT(storageUnit->Exists(ev, kODPropIsSubframe, kODBoolean, 0), kODErrInvalidPersistentFormat);
  2509.         ASSERT(storageUnit->Exists(ev, kODPropIsOverlaid, kODBoolean, 0), kODErrInvalidPersistentFormat);
  2510.         ASSERT(storageUnit->Exists(ev, kODPropIsFrozen, kODBoolean, 0), kODErrInvalidPersistentFormat);
  2511.     
  2512.         // Note: kODPropLinkStatus is not a required property
  2513.  
  2514.         somSelf->CommonInitFrame(ev);
  2515.     
  2516.         ODULong valueSize = 0;
  2517.         ODStorageUnit* su = somSelf->GetStorageUnit(ev);
  2518.         ODSession* session = su->GetSession(ev);
  2519.         ODType typeString;
  2520.     
  2521.         // don't internalize _fContainingFrame - be lazy and do it later
  2522.         
  2523.         // geometry - must use biasTransform to normalize
  2524.         
  2525.         TempODTransform biasTransform = // DMc refcount - make temp
  2526.             ReadAndAcquireTransformIfAny(ev, su, kODPropBiasTransform);
  2527.         
  2528.         _fFrameShape = ReadAndAcquireShapeIfAny(ev, su, kODPropFrameShape);
  2529.         if ( !_fFrameShape )
  2530.             THROW(kODErrInvalidPersistentFormat);
  2531.         if ( _fFrameShape && biasTransform )
  2532.             _fFrameShape->Transform(ev, biasTransform);
  2533.         
  2534.         _fInternalTransform = ReadAndAcquireTransformIfAny(ev, su, kODPropInternalTransform);
  2535.         if ( _fInternalTransform && biasTransform )
  2536.             _fInternalTransform->PreCompose(ev, biasTransform);
  2537.     
  2538.         // don't internalize _fPart or _fPartInfo
  2539.         
  2540.         // internalize viewType and presentation
  2541.     
  2542.         typeString = ODGetISOStrProp(ev, su, kODPropViewType, kODISOStr, kODNULL, &valueSize);
  2543.         if ( valueSize > 0 )
  2544.             _fViewType = session->Tokenize(ev, typeString);
  2545.         if (typeString)
  2546.             ODDisposePtr(typeString);
  2547.         
  2548.         typeString = ODGetISOStrProp(ev, su, kODPropPresentation, kODISOStr, kODNULL, &valueSize);
  2549.         if ( valueSize > 0 )
  2550.             _fPresentation = session->Tokenize(ev, typeString);
  2551.         if (typeString)
  2552.             ODDisposePtr(typeString);
  2553.         
  2554.         // _fIsRoot set if containingFrame is valid suRef
  2555.         if ( ODSUExistsThenFocus(ev, su, kODPropContainingFrame, kODWeakStorageUnitRef) )
  2556.         {
  2557.             ODStorageUnitRef value;
  2558.             StorageUnitGetValue(su, ev, kODStorageUnitRefLen, (ODValue)&value);
  2559.             _fIsRoot = !(su->IsValidStorageUnitRef(ev, value));
  2560.         }
  2561.         else
  2562.             _fIsRoot = kODTrue;
  2563.  
  2564.         
  2565.         _fFrameGroup      = ODGetULongProp(ev, su, kODPropFrameGroup, kODULong);
  2566.         _fSequenceNumber = ODGetULongProp(ev, su, kODPropSequenceNumber, kODULong);
  2567.         _fIsSubframe     = ODGetBooleanProp(ev, su, kODPropIsSubframe, kODBoolean);
  2568.         _fIsOverlaid     = ODGetBooleanProp(ev, su, kODPropIsOverlaid, kODBoolean);
  2569.         _fIsFrozen         = ODGetBooleanProp(ev, su, kODPropIsFrozen, kODBoolean);
  2570.     
  2571.         if ( su->Exists(ev, kODPropLinkStatus, kODULong, 0) )
  2572.             _fLinkStatus = ODGetULongProp(ev, su, kODPropLinkStatus, kODULong);
  2573.  
  2574.         _fDirty = kNotDirty;
  2575.     SOM_CATCH_ALL
  2576.     SOM_ENDTRY
  2577. }
  2578.  
  2579. //------------------------------------------------------------------------------
  2580. // ODFrame: InitFrameNonPersistent
  2581. //------------------------------------------------------------------------------
  2582. SOM_Scope void  SOMLINK ODFrameInitFrameNonPersistent(ODFrame *somSelf, Environment *ev,
  2583.                 ODDraft*    draft,
  2584.                 ODID         id,
  2585.                 ODFrame*     containingFrame,
  2586.                 ODShape*     frameShape,
  2587.                 ODCanvas*    biasCanvas,
  2588.                 ODPart*     part,
  2589.                 ODTypeToken    viewType,
  2590.                 ODTypeToken    presentation,
  2591.                 ODBoolean    isSubframe,
  2592.                 ODBoolean     isOverlaid)
  2593. {
  2594.     ODFrameData *somThis = ODFrameGetData(somSelf);
  2595.     ODFrameMethodDebug("ODFrame","InitFrameNonPersistent");
  2596.  
  2597.     // *DON'T* CHECKVALID - new frames will never be invalid
  2598.     
  2599.     SOM_TRY
  2600.         if ( kODNULL == draft )            THROW(kODErrIllegalNullStorageUnitInput);
  2601.         if ( kODNULL == frameShape    )    THROW(kODErrIllegalNullShapeInput);
  2602.         if ( kODNULL == part )            THROW(kODErrIllegalNullPartInput);
  2603.         if ( kODNULL == viewType )        THROW(kODErrIllegalNullTokenInput);
  2604.         if ( kODNULL == presentation )    THROW(kODErrIllegalNullTokenInput);
  2605.             
  2606.         // check for recursive embedding
  2607.         if ( (containingFrame != kODNULL) && !isSubframe )
  2608.         {
  2609.             TempODFrame tempFrame = containingFrame;
  2610.             tempFrame->Acquire(ev);   // because it will be released below
  2611.             while ( tempFrame )
  2612.             {
  2613.                 TempODPart tempPart = tempFrame->AcquirePart(ev);
  2614.                 if (tempPart == part)
  2615.                     THROW(kODErrIllegalRecursiveEmbedding);
  2616.                 ODFrame* spam = tempFrame;
  2617.                 TempODFrame oldFrame = spam;
  2618.                 tempFrame = kODNULL; // to avoid double Release if following fails
  2619.                 tempFrame = oldFrame->AcquireContainingFrame(ev);
  2620.             }
  2621.         }
  2622.  
  2623.         somSelf->InitPersistentObject(ev, kODNULL);
  2624.     
  2625.         _fLinkStatus = kODNotInLink;
  2626.         _fDraft = draft;
  2627.         _fNPID = id;
  2628.         
  2629.         _fContainingFrame = containingFrame;
  2630.         ODAcquireObject(ev, _fContainingFrame);
  2631.     
  2632.         _fFrameShape = BiasShapeSet(ev, frameShape, biasCanvas);
  2633.         ODAcquireObject(ev, _fFrameShape);
  2634.     
  2635.         _fInternalTransform    = somSelf->CreateTransform(ev);
  2636.         _fContentExtent        = ODPoint(0,0);
  2637.     
  2638.         _fViewType        = viewType;
  2639.         _fPresentation    = presentation;
  2640.         _fIsRoot        = (containingFrame == kODNULL);
  2641.         _fIsSubframe    = isSubframe;
  2642.         _fIsOverlaid     = isOverlaid;
  2643.     
  2644.         somSelf->CommonInitFrame(ev);
  2645.         
  2646.         _fPart = part;
  2647.         ODAcquireObject(ev, _fPart);
  2648.         _fPart->DisplayFrameAdded(ev, somSelf);
  2649.     SOM_CATCH_ALL
  2650.     SOM_ENDTRY
  2651. }
  2652.  
  2653. //------------------------------------------------------------------------------
  2654. // ODFrame: ReleaseAll
  2655. //------------------------------------------------------------------------------
  2656.  
  2657. SOM_Scope void  SOMLINK ODFrameReleaseAll(ODFrame *somSelf, Environment *ev)
  2658. {
  2659.     ODFrameData *somThis = ODFrameGetData(somSelf);
  2660.     ODFrameMethodDebug("ODFrame","ReleaseAll");
  2661.  
  2662.     // *DON'T* CHECKVALID - still need to finalize invalid frames
  2663.     
  2664.     SOM_TRY
  2665.         ODSafeReleaseObject(_fContainingFrame);
  2666.         ODSafeReleaseObject(_fWindow);
  2667.         ODSafeReleaseObject(_fPart);
  2668.  
  2669.         ODSafeReleaseObject(_fFrameShape);
  2670.         ODSafeReleaseObject(_fUsedShape);
  2671.         ODSafeReleaseObject(_fInternalTransform);
  2672.     
  2673.         parent_ReleaseAll(somSelf,ev);
  2674.     SOM_CATCH_ALL
  2675.     SOM_ENDTRY
  2676. }
  2677.  
  2678. //------------------------------------------------------------------------------
  2679. // ODFrame: somUninit
  2680. //------------------------------------------------------------------------------
  2681.  
  2682. SOM_Scope void  SOMLINK ODFramesomUninit(ODFrame *somSelf)
  2683. {
  2684.     ODFrameData *somThis = ODFrameGetData(somSelf);
  2685.     ODFrameMethodDebug("ODFrame","somUninit");
  2686.     
  2687.     ODDeleteObject(_fFacets);
  2688. }
  2689.